← All papers
First page of The LLMbda Calculus: AI Agents, Conversations, and Information Flow

The LLMbda Calculus: AI Agents, Conversations, and Information Flow

Zac Garby, Andrew D. Gordon, David Sands

cs.PL Feb 23, 2026 · v2 cs.AI cs.CR
Mechanises the LLMbda calculus, its noninterference theorems, and an executable verified LLM agent-harness interpreter in Lean 4.
Large language models are increasingly deployed as agents: they plan, call tools, read untrusted data, and act on the results. This exposes them to prompt injection: data meant only to be read is obeyed as an instruction. The most principled defences replace content inspection with provenance: classifying data by source and keeping trusted and untrusted apart through a separation of duty (the dual-LLM pattern) and information-flow control. Yet the leading systems are hard to fully trust: flow tracking is easy to get wrong, deliberate relaxations are hard to audit, and the dual-LLM pattern is hard-wired into the architecture. We present LLMbda, an untyped call-by-value lambda calculus that makes provenance-based defence both expressible and provably sound, without committing to an architecture. It adds the operational core of agentic systems as first-class constructs: prompt-response conversations that can be forked and cleared, code generation, and dynamic information-flow control in which every value carries a label that every reduction propagates. Isolation becomes a policy a program expresses, and reclassification an explicit, auditable construct. Our central result is a termination-insensitive probabilistic noninterference theorem over the whole calculus, including code-generating agents, with an insulated variant that holds even when the attacker chooses all untrusted inputs. The verified interpreter is itself the harness that calls the model, to our knowledge the first LLM agent harness whose executable is the subject of machine-checked security theorems, so every agent inherits the guarantee. On the AgentDojo banking benchmark, an agent built within LLMbda, enforcement always on, matches the utility of CaMeL, a leading dual-LLM defence, run without its policy checks (which halve its utility), and resists all but two of 1296 attacked runs. Our harness and all proofs are in Lean.

LLM agents are vulnerable to prompt injection. Provenance-based defences such as the dual-LLM pattern and information-flow control are hard to trust because flow tracking is error-prone, relaxations are hard to audit, and the architecture is hard-wired.

LLMbda is an untyped call-by-value lambda calculus with first-class constructs for prompt-response conversations (fork, clear), code generation, and dynamic information-flow labels propagated by every reduction. Endorsement is an explicit, auditable construct. A termination-insensitive probabilistic noninterference theorem is proved for the whole calculus, along with an insulated variant for attacker-chosen inputs. A fuel-based Lean interpreter that calls a real LLM through an opaque oracle is proved to agree with the denotational semantics.

The interpreter is claimed to be the first LLM agent harness whose executable is the subject of machine-checked security theorems. On the AgentDojo banking benchmark, an LLMbda agent with enforcement always on matches the utility of CaMeL run without its policy checks, and resists all but 2 of 1296 attacked runs.