Table of Contents
Fetching ...

Managing the Stochastic: Foundations of Learning in Neuro-Symbolic Systems for Software Engineering

Matthew Thompson

TL;DR

This work formalizes a Dual-State Architecture that separates deterministic workflow control from stochastic LLM content generation by coupling generation with deterministic verification in Atomic Action Pairs governed by Guard Functions. By modeling the environment as an append-only versioned repository and projecting generation outcomes onto a finite workflow state, the framework enables reliable code generation using smaller, locally deployed models. Theoretical guarantees on convergence and finite planning complexity are coupled with experimental validation across 13 models and multiple tasks, showing up to 66 percentage point improvements at modest computational overhead. The approach reframes AI safety as a systemic property of architecture rather than an intrinsic model constraint, offering practical pathways for iterative refinement, online/offline learning, and standardized control benchmarks.

Abstract

Current approaches to AI coding agents appear to blur the lines between the Large Language Model (LLM) and the agent itself, asking the LLM to make decisions best left to deterministic processes. This leads to systems prone to stochastic failures such as gaming unit tests or hallucinating syntax. Drawing on established software engineering practices that provide deterministic frameworks for managing unpredictable processes, this paper proposes setting the control boundary such that the LLM is treated as a component of the environment environment -- preserving its creative stochasticity -- rather than the decision-making agent. A \textbf{Dual-State Architecture} is formalized, separating workflow state (deterministic control flow) from environment state (stochastic generation). \textbf{Atomic Action Pairs} couple generation with verification as indivisible transactions, where \textbf{Guard Functions} act as sensing actions that project probabilistic outputs onto observable workflow state. The framework is validated on three code generation tasks across 13 LLMs (1.3B--15B parameters). For qualified instruction-following models, task success rates improved by up to 66 percentage points at 1.2--2.1$\times$ baseline computational cost. The results suggest that architectural constraints can substitute for parameter scale in achieving reliable code generation.

Managing the Stochastic: Foundations of Learning in Neuro-Symbolic Systems for Software Engineering

TL;DR

This work formalizes a Dual-State Architecture that separates deterministic workflow control from stochastic LLM content generation by coupling generation with deterministic verification in Atomic Action Pairs governed by Guard Functions. By modeling the environment as an append-only versioned repository and projecting generation outcomes onto a finite workflow state, the framework enables reliable code generation using smaller, locally deployed models. Theoretical guarantees on convergence and finite planning complexity are coupled with experimental validation across 13 models and multiple tasks, showing up to 66 percentage point improvements at modest computational overhead. The approach reframes AI safety as a systemic property of architecture rather than an intrinsic model constraint, offering practical pathways for iterative refinement, online/offline learning, and standardized control benchmarks.

Abstract

Current approaches to AI coding agents appear to blur the lines between the Large Language Model (LLM) and the agent itself, asking the LLM to make decisions best left to deterministic processes. This leads to systems prone to stochastic failures such as gaming unit tests or hallucinating syntax. Drawing on established software engineering practices that provide deterministic frameworks for managing unpredictable processes, this paper proposes setting the control boundary such that the LLM is treated as a component of the environment environment -- preserving its creative stochasticity -- rather than the decision-making agent. A \textbf{Dual-State Architecture} is formalized, separating workflow state (deterministic control flow) from environment state (stochastic generation). \textbf{Atomic Action Pairs} couple generation with verification as indivisible transactions, where \textbf{Guard Functions} act as sensing actions that project probabilistic outputs onto observable workflow state. The framework is validated on three code generation tasks across 13 LLMs (1.3B--15B parameters). For qualified instruction-following models, task success rates improved by up to 66 percentage points at 1.2--2.1 baseline computational cost. The results suggest that architectural constraints can substitute for parameter scale in achieving reliable code generation.
Paper Structure (72 sections, 8 theorems, 23 equations, 2 figures, 8 tables, 1 algorithm)

This paper contains 72 sections, 8 theorems, 23 equations, 2 figures, 8 tables, 1 algorithm.

Key Result

Lemma 1

If a generator produces artifact $a$, then guard evaluation $G(a, C)$ is deterministic regardless of whether the generator itself is deterministic.

Figures (2)

  • Figure 1: The Atomic Action Pair. The architecture enforces a strict separation between the Observable Workflow (left) and the Opaque Environment (right). The red loop illustrates the refinement transition: unlike standard backtracking, the workflow state $s_w$ remains invariant while guard feedback $\phi$ updates the generative context $C$. The dotted line indicates that the Guard conditions validation on both the artifact and the context.
  • Figure 2: Guarded Success Rate by Model and Task. Heatmap showing task-specific model qualification under the guarded configuration ($R_{max}=3$). Green cells indicate high reliability ($\geq$90%), yellow indicates partial success, and red indicates failure to converge. Notable patterns: DeepSeek-Coder (1.3B) shows uniform failure across all tasks ($\epsilon=0$), establishing the canonical "unqualified" baseline; Phi4-Mini exhibits task-specific qualification (58% LRU, 0% password); the Qwen2.5-Coder (14B) password anomaly (0%) reflects data corruption rather than model capability.

Theorems & Definitions (31)

  • Definition 1: State Space Decomposition
  • Remark 1: Information Abstraction
  • Definition 2: Artifact Space & Versioning
  • Definition 3: Hierarchical Context Composition
  • Remark 2: Context Isolation
  • Definition 4: Workflow Stability
  • Definition 5: Context Refinement
  • Definition 6: Action Pair
  • Remark 3: Guard Input Scoping
  • Definition 7: System Dynamics
  • ...and 21 more