Summary
The paper presents LeanGuard, a runtime guard that intercepts every tool call an LLM agent proposes and admits it only if a policy written in Lean 4 holds. Policies combine state predicates with scoped past-time temporal operators (previous/once/since, with windows and principal/conversation/resource scopes). Evaluation is fail-closed, and the executable decision procedure is proved in Lean to agree with a LeanLTL semantics of the policy (Eq. 1, Theorem 1). After a denial, the agent can get feedback (the violated rule ids plus an unverified natural-language hint). Separately, an offline Lean tactic guard_repair? searches a finite set of candidate edits for a call the policy admits and returns a kernel-checked proof of admissibility (Eq. 2).
Five Qwen models (0.8B–27B) are evaluated on 278 τ²-bench tasks and seven DTap domains. Main claims: (i) unguarded agents execute at least 33 Lean-forbidden calls on τ² and LeanGuard executes none, while LG+F task success (70.9%) is not significantly below the unguarded 72.7%; (ii) under a read-only DTap deployment, direct prompt-injection success falls from 57.9% to 5.9% and indirect from 22.3% to 3.8%, but benign success falls from 53.1% to 12.5% outside telecom; (iii) feedback reduces repeated blocked calls (983→719) and raises recoveries (34→48) relative to bare denial; (iv) repair proves an admissible edit for 88 of 252 argument-value denials, median 2 ms. A five-category taxonomy of agent failures (invalid invocation, state, temporal, authorization, prohibition) organises the analysis.
Strengths
The formal core is machine-checked and is the code the runtime runs
Sec. 2.3–2.4, Theorem 1; App. B; LeanGuard/PolicyProofs.lean, TemporalProofs.lean
I built the repository with Lean v4.33.1 (
lake build LeanGuardProofs LeanGuardAudit, 8,752 jobs, 0 errors). The repo's axiom audit passed for 1,442 declarations, anddecision_leanLTL_correct,holds_iff_leanLTL,authorize_leanLTL_correctandrepair_iff_leanLTLdepend only onpropext,Classical.choiceandQuot.sound. The code proves an iff, which is stronger than the one-directional Theorem 1. The runtime admission path calls the proveddecidePolicy(RuntimeCore.lean:184), and the Python host spawns the compiled Lean binary (checks 08, 18).Nearly every reported number reproduces from the published counts
Tables 1, 2, 8, 12–24; Sec. 3
Across 13 arithmetic checks, every count reconstruction I attempted was consistent. All 45 per-domain τ² cells have unique integer reconstructions that sum to the All-models 1011/958/986 of 1390 (Table 1, Table 12). All 72 DTap percentages match their counts, and per-model and per-domain sums agree (Tables 17, 18). DTap scored plus unscored episodes equal 5 × evaluated cases in all 7 domains (Table 8). Table 2 columns sum to 1,702 = 1,613 + 17 + 72. The repair tables sum to 252/88. Most quoted p-values reproduce (0.002, 0.30, 0.02, 0.39, 0.31, 0.16, 0.52). This level of internal consistency is uncommon (checks 01–07, 11–13, 16).