6 ms·
I accidentally turned LLM memory into program analysis
- linguae 1mo agoThis summer I’ve been investigating agentic coding with local LLMs, and while I’m far from an expert, one thought that has been on my mind is leveraging techniques from “old-school” AI such as heuristic search to guide agents when it comes to planning. The use of Datalog in this article resonates with me, since logic programming was a major part of old-fashioned symbolic AI. I’m very curious about this combination of “old-school” AI and LLMs.
- fizx 1mo agoIs this sort of re-inventing Graph RAG from another angle, or does it feel novel?
- processunknown 1mo agoIt seems more like a handrolled CodeQL
- tptacek 1mo agoIt's an agent system that basically embeds the core idea of CodeQL (Datalog extraction from codebases) and then allows a model to pose questions and answer them.
- alansaber 1mo agoMathematically, yes.
- trinsic2 1mo agoSomething of this capacity would be useful in investigating obscure hardware failures in the logs that I couldn't confirm because the problem was not being observed while the device was in my shop. the problem was surfacing in another location probably due to some set of circumstances in the software that I could recreate, or some particular peripherals that were attached. I ran into the very same problem of the LLM forgetting that we ruled out a conclusion that was verified not to be the cause as it came up further in the conversation history while I was exploring possibilities. I had to keep reminding we ruled out that conclusion prior.. I just carried on with having the LLM capture some of the supporting sources of other people experiencing the same problem and kept having to refine those sources because it was focused only on summaries, but eventually i got the sources to a point where they were good enough hypothesis that we could formulate a better conclusion on what the potential cause was.
- keeda 1mo agoVery cool. I recall an HN submission (which I can't find offhand unfortunately) that did something similar -- it used an LLM to decompose articles into a set of statements which were used to construct an entity-relationship graph of facts and events. It then queried that using conventional graph query methods, much like DataLog / Lemmalog is doing here. I remember it was particularly effective at answering timeline-based queries that LLMs (back then) sucked at. (See also Cyc: https://en.wikipedia.org/wiki/Cyc https://en.wikipedia.org/wiki/Cyc) I think approaches like this are going to be (or maybe already are?) the basis of effective grounding of LLM responses in authoritative data sources. It should be possible to pinpoint any error to an incorrect traversal or an incorrect "fact." This would work best for concrete, unambiguous facts, however; fuzzy, ambiguous or opinion-based information will probably remain the purview of LLMs.
- fenestella 1mo ago[flagged]
- vatsachak 1mo agoEventually lambda prolog will rise again
- ande-mnoc 1mo agoCtrl-F “prolog”: 0 result. :-/
- skybrian 1mo agoSearch on datalog instead.
- langs 1mo ago[dead]
- est 1mo agoVery cool article. I had a similar idea where "fact checking" should be real programs for logic correctness. But IRL it's too vague. The exploit hunting is a better use case.
- sim04ful 1mo agoI reached a similar conclusion: LLMs should only really sit at the terminals of request fulfilment. 1. User request understanding: natural language -> a more rigorous representation, in my case Datalog. 2. Result interpretation: facts and derived facts -> natural language. Between those terminals, the work should be mechanical reasoning over some ontology or formal knowledge structure. That connects to another principle I've been thinking about, which I call Weathering: useful reasoning should change the shape of the system. If an LLM has already had to infer a relation, mapping, rule, or abstraction, repeated use should wear that inference into the system so that the next similar request doesn't require discovering it again from scratch. With continued use, a weathering-capable system should therefore require less and less probabilistic intelligence for recurring work. Put another way, there should be a declining marginal cost of cognition since the products of intelligence harden into structure that can subsequently be reused and evaluated mechanically.
- i_eat_rocks 1mo ago[dead]
- tomrod 1mo agoBayesian posteriors in the wild. Love it!
- alansaber 1mo agoTheoretically but practically any LLM generated infra/classification set is going to drift due to inaccuracy and harm IR/whatever logical process you're using. I am a big fan of using a loose taxonomy but it's not been revolutionary.
- deleted 1mo ago[deleted]
- PcChip 1mo agoWhen i hear “weathering” i think of something slowly eroding away
- 1mo ago
- iamflimflam1 1mo agoThis really matches up to my experience on long research projects with Claude. It’s very hard to remove information - Claude has a habit of recording things all over the place and will happily treat things as facts even after they’ve been disproved. What is currently true can get easily contaminated with old “facts”.
- yencabulator 1mo agoOne of my rules of thumb is to minimize the amount of "negative knowledge" an LLM sees, as the concept introduced just hangs around in the context way too strong. The mnemonic I use for that is "do not think of a polar bear". https://en.wikipedia.org/wiki/Ironic_process_theory https://en.wikipedia.org/wiki/Ironic_process_theory
- bbeonx 1mo agoIt seems like you might be inventing a form of non-monotonic logic. Check out answer set programming, it actually does exactly what you want of "unlearning" facts that you've learned. Not sure if it helps in your particular instance, but it's very cool stuff and IIRC there is an implementation that extends datalog. https://en.wikipedia.org/wiki/Answer_set_programming https://en.wikipedia.org/wiki/Answer_set_programming
- coder-pm 1mo agoThis is the fact I’ve been struggling with for quite some time. It’s not because it forgets the facts, it’s because the invalidation doesn’t propagate. My way of handling that is a decision log. For every project since I started doing that it’s working great. My CLAUDE.md instruct the agent to store my every decision to the file with a metadata when I made this decision and what was the context. The agent is using this file as an index of decisions and rarely lose a track. It also helps team members to find out more about the development phases. Does your system invalidate the parts of the memory if these are not valid or relevant anymore or just store/retrieve?
- tedmartynov 1mo ago[flagged]
- igkougkousis 1mo ago[flagged]
- cookiengineer 1mo agoThis was a pretty awesome read, I liked it a lot! What I found out during malware analysis is that LLM agents have a couple of quirks that you can solve by: - optimize for short lived agent workflows - use symbols as function contracts - maintain decision and discovery state - give LLMs CLI linters - give LLMs access to knowledge bases The linter part is mindblowing. I built linters that validate HTML or markdown or docx or Go or C files, for example, and they output what kind of structure is expected instead of useless token based errors (e.g. h4 inside h1? Must be h1 > h2 ...). With linters the output quality of agents is just soo much better. For program analysis, I'm currently exploring the idea of using an external ebpf daemon that programs can be observed with via a public API (which is the tool for the agent to use). Not sure if it'll do the trick yet, but I think it has lots of potential. My stuff in case you're interested: [1] https://github.com/cookiengineer/exocomp https://github.com/cookiengineer/exocomp [2] https://github.com/cookiengineer/gobayashi https://github.com/cookiengineer/gobayashi [3] https://github.com/cookiengineer/gonano https://github.com/cookiengineer/gonano
- tomveber 1mo ago[dead]
- yomu123 1mo ago[flagged]
- mirekrusin 1mo agoYou should checkout cave lang [0] - terse language that explores this area of knowledge/graph/ontology/provenance/querying/confidence/solver etc. [0] https://mirekrusin.com/cave https://mirekrusin.com/cave
- ikari_pl 1mo agoI was trying to connect to wifi on a fresh macOS install without only a keyboard connected last week. After googling for an hour, I gave up.
- Animats 1mo agoSo he's using an LLM to generate data stored in an "is_a" representation. That's so classic AI. Soon, he'll discover that he needs quantifiers. Then that "for all" is too strong sometimes, and he needs "for most". That way lies Cyc. It's not a bad idea. But it does have a history.
- mentalgear 1mo agoIn general, what all the big LLM providers are doing is moving towards classical & neural (neuro-symbolic) AI - even though they dont publicly admit it because that would counter their claims for years of "scale is all you need" (which has vanished with diminishing returns, see $MS / altman's GPT-5 bet).
- akkad33 1mo agoHow do you know this?
- pegasus 1mo agoThey're probably referring to tech like reasoning models, or agent harnesses for example, which are arguably slowly moving things towards the symbolic end of the spectrum.
- mentalgear 1mo agoLLMs using REPL are one instance of symbols to "bounce" their prediction against domain constraints for verification. Also shout out to Gary Marcus who was right after all (and LLM companies wasting 100s of billions of dollars for years in-between on pure scaling).
- deleted 1mo ago[deleted]
- doginasuit 1mo agoIt seems like the two approaches compliment each other nicely. Human intelligence also relies on parallel information processing. LLMs are like a massive working memory, incredibly effective but with a similar set of limitations. What they lack is a symbolic model of reality, something that they can build and refine.
- locitra 1mo ago[flagged]
- schmuhblaster 1mo agoGreat work! If anyone is looking for a way to integrate something like this into their own harness or the pi coding agent, then you might be interested in DeepClause [0]. It comes with a Prolog-like language implemented on top of SWI-Prolog (WASM Version). The purpose of the project is to allow for broad experimentation around the intersection of LLMs/Agents and GOFAI. So you could use it to build memory systems like OP did, create executable specs, define graphs and loops for agents and subagents... It also comes with a pi extension that greatly simplifies getting started with it. Opposed to OP, DeepClause uses Prolog semantics, so running some more complex queries on knowledgebases might cause some issues (which is the use case where a Datalog might be more useful). For smaller scales it should be fine though. [0] https://github.com/deepclause/deepclause-sdk https://github.com/deepclause/deepclause-sdk [1] https://github.com/deepclause/deepclause-pi https://github.com/deepclause/deepclause-pi
- ALLTaken 1mo agoI'm not sure if this is the right direction, but it's certainly momentarily helpful. I think the right direction would be to enable the model itself do dynamic program analysis, deterministically and dynamically via runtime-inference. btw. your comment is grayed out, not sure what it means. However, thanks for sharing, I'll look into it.
- zyralab 1mo ago[flagged]
- egberts1 1mo agoLimitation of LLM for and toward reverse engineering; it's the LLM innate error of forgetting states thru agentic recursion by overflow of context or prior premises being optimized away due to not using ternary-state (uninit/written/read) memory state. Once again, on LLM being: a digital librarian, at its finest; logic a logic analyst, not so much.
- jjp 1mo agoInteresting and potentially has applicability in deriving logical rules from regulation, contracts etc. Are there already formal languages that can be used to codify, that sort of information.
- onoesworkacct 1mo agoyooo.. this is exactly what I wanted to do... I'm so happy because (a) I hadn't figured out how to do it (b) it seemed kind of difficult in general and (c) now I don't have to, lol.
- marthoswe 1mo ago[dead]
- akkad33 1mo agoI had tried to get long term memory out of Claude by indexing my notes with keywords and putting that in a sqllite database and Claude queries using full text search. Don't know how good it is, it seems to find things alright. My goal was to keep context small and only get Claude to ask for what it needs. Datalog seems like a great idea, will definitely try it out
- akkad33 1mo agoHas anyone tried formal verification with AI generated code? I can't convince my company to use it but I realise it's very easy to ask Claude to add a verification step locally on my own PRs
- insanitybit 1mo agoAt one point I was using TLA+ but it just made the problem "is the spec right?" or "does the code match the spec?". I could ensure that the properties defined in the spec were valid, but that didn't seem to translate into confidence that my code was correct. Maybe I was holding it wrong, it was just an experiment in an area I'm unfamiliar with. Ultimately I have stuck to the informal verification of defining my expectations and ensuring that tests cover them.
- akkad33 1mo agoI don't know TLA+ but indeed that seemed to be the limitation when I read about it too. What about languages like Dafny, that allow you to "prove" your programs?
- apt-apt-apt-apt 1mo agoIs this the kind of thing that works when you have a tight domain-specific language, but devolves into natural language (English) eventually? E.g. A -> B, B -> C so A -> C (works, great). A -> B when A is sort of red and blue, also A is intermittent (what to do now?)
- sigbottle 1mo agoYeah, philosophy of science & analytic philosophy (especially with Quine) has been down this rabbit hole before. Formalisms should be in service to higher-level intelligences, not the other way around. It's pretty clear that LLM's are intelligent inherently; the lean doesn't just "prove math itself". (Admittedly, I'm not full blown AGI pilled either - there are some structural constraints that do make me think there is room to be gained in intelligence. And formalism will play a part in that. But it's not the end-all be-all to it).
- frumiousirc 1mo agoDatalog seems like a way to "spell" knowledge graph (KG). The article touches on Datalog statements changing over time. One ingredient I think would be good to add to the system is to make every statement carry "providence" metadata. The providence should be sufficient to enable later confirmation that a statement is still valid or if the statement needs to be reformed without the need to remake the entire graph from scratch. I would make at least some forms of providence follow a strict schema that is defined for the subject matter that is being captured. For example, statements about a code base should refer to the source files and their version (file modification date, content hash) from which the statements were concluded. When a source file is modified we may then find all statements made from them and reevaluate just those statements. The next level would be to keep statements even if reevaluation breaks them and add a method to derive a subgraph for a given state of the subject. For example, over many releases of a code base, a lot of statements would not change, some would. Having a graph that spans all conclusions about all releases of a code base and a way to form the subgraph for a specific release would allow the system to efficiently target queries for a particular release.
- GrinningFool 1mo ago*provenance
- pixelsort 1mo agoThe OP rediscovered that frontier models prefer to reason over logical scaffolding for complex tasks. They excel at technical work with many constraints as they can perfectly maintain the references, flow graph, and evidence states while they works through your conformance gates. Many people here might disagree; but they're holding it wrong. Those folks should ask: 1. Am I using free tier tokens? 2. Am I working on trivial software? 3. Am I expecting models to adapt to my ways of thinking? Anyone affect by any of these three mistakes will maintain an impenetrable filter of perpetual ignorance about model capabilities. Since the OP came with receipts, I'm reproducing an example graph below. From a plan in my active research project: Phase 0 resolve -> vendor -> pin [USER+agent] -> G0 CORPUS-RESOLVED [PASS] Track B B1 Abusalah [WRITTEN] [agent] -> G1B Q-BOUNDARY B2 Guan-Riazanov-Yuan [WRITTEN] (KILL-BOUNDARY risk) B3 Mahmoody-Smith-Wu [WRITTEN] + O-MSW-VERIFIER-COST closed (t = 588, MEASURED) -> G1B PASSED: BOUNDARY-ESTABLISHED Track A 05 Binius [WRITTEN] [agent] -> G1 AUDITS-COMPLETE [PASS] 2026-08-28 07 FRI-Binius 2024/504 [WRITTEN] — vendored by USER; calculated Q-FLOOR point obtained 06 HOBBIT [WRITTEN] — O-QUEUE-M escalated to 179 Phase 2 01 Wesolowski [WRITTEN] — hinge splits; C_overlap = 0, C_tail = 57.50% computed 02 Tight VDFs [WRITTEN] — no omega; O(log T) proof threads; black-box RO base impossible 03 LaBRADOR (light) [WRITTEN] — calculated, not measured; translation remains open 04 LatticeFold+ -- deferred to pre-141 Track C [PASS] C0a contract -> C0b exact simulator -> G0C TRANSLATION-READY C2 Alwen-Serbinenko [TECHNIQUE-ONLY] -> C1 SoW [PASS] ANCESTRY-FOUND -> C4 Seeded PoW [FORM-ONLY] -> G1C [RED] WORK-LEMMA-MISSING [WARN] ANCESTRY-CLASSICAL -> L0 [PASS] SCOPE-FROZEN |- E0 response [PASS] PRESENT `- L1-L2 local [PASS] CARRIER-QUOTIENT -> J0 [PASS] TECHNIQUE-FIT CONFIRMED -> admission decision [PASS] CANONICAL RESULT -> A0 [AMBER] REFERENCE-TESTED -> A1 [PASS] ROOT-LEAF FEASIBILITY LEAD -> semantic equivalence + epoch [USER] C3, C5 -- deferred to pre-141 Phase 2 Q-TAIL / Q-FLOOR synthesis [agent] -> [PASS] G2: TAIL-MECHANISM-FOUND · FLOOR-OPEN Phase 3 reference ledger for 141 [agent] -> CLOSED; awaits fresh USER authorization
- alexpotato 1mo agoI recently stumbled upon the technique of asking the LLM to create a Dot Viz (or mermaid) flowchart of the program flow. The LLMs are great at: - understanding the flow - making diagrams - running the code with logging they add to to even better understand the flow The flow being in Dot (or other machine readable format) makes it even easier for the LLM to use that as a reference going forward.
- aiman_alsari 1mo agoYeah I do something similar. I've been using mermaid to create attack trees and as we explore the codebase for vulnerabilities we keep the tree up to date. This is how I used to do it before LLMs too, it's just way faster now
- alexpotato 1mo ago> The LLM handles the fuzzy part: > And Lemmalog handles the deterministic part: There seems to be this view in some circles that the LLM should do EVERYTHING. The most extreme version of this was "just commit the prompt, bro". The more I've used LLMs, the more I think that the LLM should do either: 1. the fuzzy parts as mentioned in the post 2. helping to write deterministic tools to expand the "non-fuzzy" part For #2, we invented code to run the same instructions the same way over and over again for very, very low cost. The code is also easy to read and modify as needed. Why we would replace the above with a smart but stochastic system still seems strange to me.
- mgr86 1mo agoAnd here I am just having them author org-files for me and them to refer back too. For fun I even ask for DITA sometimes.
- 4b11b4 1mo agoHmm DITA..
- jarboot 1mo agoI encountered this with trying to have LLMs populate facts about electoral campaigns. Like when a candidate drops out, when endorsements happen, but also if a candidate is un-endorsed or drops and rejoins. It also needed to handle if any of these facts were incorrect. I settled on a knowledge graph in Postgres and downloading/storing the source documents so it could iterate on past results without more scraping or network calls. This blog post helped me understand security analysis in this context! A lot of the important systems around malware analysis or large scale system security (the parts people really care about) clicked for me. So thanks for writing it. Anyways I hope we can find some pattern to converge on with this wrt "facts management" since I feel this is currently something a lot of people and LLMs are struggling with. In practice current LLMs working with episodic memory feels similar to a grandparent with dementia scrawling things down in notebooks, crossing things out, and getting very confused.
- mirekrusin 1mo agoI had similar problems to solve for trading advice, complex project reasoning etc. I settled on simplicity, extended it to serve clear, useful purpose. Started with markdown database, single fact per line, structured/parseable (subject VERB object). This can be easily diffed/reviewed etc in git. Then added optional metadata (confidence, tags, persisted comments for natural language, uncertainty for numeric values, context, timestamps/spans), querying, alternative sqlite3 backend, self describing VERBS, z3 solver etc. Those kind of graph information systems are great to quickly structure knowledge in a way that LLMs and humans can use/act on/loop on. Creating ontology, linking, some rules and actions and kicking it so it all munches and spits out results that feed back in so it self evolves. It's very natural for llms to query/update/restructure those graphs (also good for humans because it's very terse, essential information only). There is no need to create k8s style complexity/services/what-not, it all works well from single sqlite db file or bunch of markdown (.cave in my case) files. It's also interesting to see how well local open weight models are dealing with information arranged this way.
- felixlu2026 1mo ago[dead]
- kaeluka 1mo agoI’ve been toying with using an llm to compile to smtlib and solving with z3. It works quite well, although I’m not quite sure how practical (large programs, reliably good runtime) I can make it.
- imdsm 1mo agoReading this site hurt my eyes
- alexwynn 1mo ago[flagged]
- syou1024 1mo ago[flagged]
- luke-stanley 1mo agoI couldn't quite figure out Lemmalog's latest benchmark stats from the README but it sounds cool! I heard of Scallop, that also uses Datalog for neurosymbolic programming, I wonder where Lemmalog fits with Scallop? I know little about Datalog so sorry if this is a dumb question!
- jnpnj 1mo agoIsn't that why we created models and graphs before ? Maybe now the uml to source roundtrip can be solved with LLMs. Back in 2010s that's where it was stuck. Note: I wonder how many people reified their codebase as logical facts to query or investigate it more deterministically. I've been trying for a while, still not far but getting there.
- soricus 1mo ago[flagged]
- Goofy_Coyote 1mo agoWhat a great write up. One of the few long form contents that I just opened and read from top to bottom without planning for it or keeping the tab open to read later. Great job. I’ve been battling the same problem, and I solved it by keeping the state in my brain, long focus hours, and breaking down the problem to smaller chunks that agents could almost one-shot. That made me the bottleneck, and although I can do it for codebases I’m familiar with, working on totally new projects has been very painful. I’m going to test it in my own vuln research workflow.
- foremerge 1mo ago[flagged]
- ianhorn 1mo agoThat’s practically what i’m working on! But i’m training the models to do this natively. It gets complex given the inherent relevant uncertainties (aka making it resilient to their bullshit). Luckily, datalog and monotonic logic in general is reasonably amenable to packed representations of the possible knowledge bases, and reasoning from them in a way that lends itself to decent UX, but it’s been a huge amount of elbow grease to get working with reasonable complexity end-to-end.
- mic_sm 1mo agoSounds interesting for me, could you share a link of POC?
- gregwebs 1mo agoThe way to control LLM memory with existing tools now is to ask it to write out a file with all relevant information (this could include explicit retraction instructions). Then clear out the context. Basically /compact. I use workflows with sub agents handing off .md files: https://github.com/gregwebs/skills-sdlc/blob/main/skills/implement/SKILL.md https://github.com/gregwebs/skills-sdlc/blob/main/skills/imp... What the author is doing is probably the future- it should be a lot more efficient to maintain a database of relationships.
- anktor 1mo agoIt's my first time hearing of program analysis but the core seems related to what I studied at college and never used again, which was prolog. Could anyone with more experience give feedback on whether this approach would be useful for business rules? Particularly for debugging a data pipeline where dozens if not hundred of different values at different points in time may have different implications. Would it be useful to provide this tools for Business Analysts so they have something more solid for they analysis?
- mr_big_bowls 1mo ago[flagged]
- dramebaaz 1mo agoThis reminds me of Automated Reasoning where the model maintains a form of lean code which gets run to verify assumptions constantly as the model builds a knowledge base
- mr_big_bowls 1mo ago[dead]
- trash_cat 1mo agoagent memory | +--------------+--------------+ | | deductive state episodic memory | | facts / rules / time fuzzy context provenance semantic retrieval retractions source text Well this turns out, just like human memory functions. (Semantic vs episodic memory)
- tomaskafka 1mo agoI’ve been playing with this too, the OP is rediscovering the whole field of AI before LLMs. Prolog, temporal logic … The next one is ontology and semantic web, for which the “trying to stem verbs and nouns” is a crude v0.1 attempt.
- kris-memoket 1mo ago[flagged]
- deleted 1mo ago[deleted]