Abstract
Recent results in learning a language in the limit have shown that, although language identification is impossible, language generation is tractable. As this foundational area expands, we need to consider the implications of language generation in real-world settings. This work offers the first theoretical treatment of safe language generation. Building on the computational paradigm of learning in the limit, we formalize the tasks of safe language identification and generation. We prove that under this model, safe language identification is impossible, and that safe language generation is at least as hard as (vanilla) language identification, which is also impossible. Last, we discuss several intractable and tractable cases.
Introduction
As Large Language Models (LLMs) are increasingly deployed in high-stakes environments, ensuring they do not generate harmful content—such as toxic speech or dangerous advice—has become a primary concern. Current industry standards rely on empirical methods like safety benchmarks, data filtering, and Reinforcement Learning from Human Feedback (RLHF). However, these methods lack a foundational mathematical guarantee. This paper addresses the fundamental question: Is "safe generation" even computationally possible?
The authors frame this inquiry within the classic "learning in the limit" paradigm established by Gold (1967). While previous research demonstrated that generating valid strings from a target language is tractable even when identifying the language is not, this work reveals that adding safety constraints fundamentally changes the complexity of the task.
Problem Formulation and Setup
The study formalizes two new computational tasks: Safe Language Identification (SI) and Safe Language Generation (SG). In this setup, a learner observes a stream of strings labeled as belonging to a target language ($K$) or a harmful language ($H$). The goal of $SG$ is to output novel strings that are in $K$ but strictly not in $H$ (the set $K \setminus H$).
The learner receives a sequence of words $w_t$ at each timestep $t$, forming a set $S_t$. The challenge lies in the fact that the learner never knows if the current set of observations is sufficient to distinguish between safe and harmful regions of the language space.
The Impossibility of Safe Generation
The core finding of this research is a "safety-tractability gap." While standard language generation is solvable, safe language generation is not. The authors employ mathematical reductions and diagonalization to establish these limits.
Key Theorems
- Theorem 3.1 (Impossibility of SI): No algorithm can reliably identify the exact boundaries of a safe language ($K \setminus H$) in the limit.
- Theorem 5.1 (Hardness of SG): Safe Language Generation is at least as hard as standard Language Identification ($LI$). Since $LI$ is known to be impossible for many language classes, $SG$ is similarly intractable.
- Theorem 6.2 (Oracle Limits): Even with an "oracle" that determines if the safe set is empty, $SG$ remains impossible in the general case due to adversarial edge cases.
- The "Empty Difference" Problem: A significant hurdle is that the safe set $K \setminus H$ might be empty. Deciding this for infinite sets is undecidable, analogous to the Halting Problem. An algorithm cannot distinguish between a safe string that hasn't appeared yet and a situation where no safe strings exist.
Tractable Cases and Structural Guarantees
Despite the general impossibility results, the paper identifies specific conditions under which safe generation becomes possible. Theorem 6.3 proves that $SG$ is tractable if there is a structural guarantee that the set difference $K \setminus H$ is always infinite. In such cases, the learner is guaranteed to eventually find valid, safe strings regardless of the specific languages involved.
Conclusion
This work demonstrates that safety constraints elevate the complexity of text generation to the level of language identification. The results suggest that unless we can make specific structural assumptions about what constitutes "harmful" language, universal safety in generation is mathematically unreachable in the limit. Future research should focus on narrowing the definitions of safety to find the boundary between these foundational limits and practical LLM safety.
Summary updated