🤖 AI Summary
This work addresses the challenge of efficiently and securely validating nested-structure inputs, such as SQL parameters with parentheses, by introducing a novel approach that integrates ultrametric spaces with automata theory. The method defines a distinguishing-word ultrametric over language equivalence classes to construct depth-bounded deterministic finite automata. Leveraging the contraction mapping property of guarded language operators, it employs Picard iteration to converge to a unique language fixed point, thereby guaranteeing correctness up to a bounded nesting depth. Notably, this is the first application of ultrametric spaces to automaton construction, enabling runtime validation with O(1) memory overhead. The resulting mechanism serves as a highly efficient pre-filter in web application firewalls, offering strong security assurances while substantially reducing both computational and memory costs.
📝 Abstract
We equip language-equivalence classes of deterministic finite automata with a distinguishing-word ultrametric and identify the resulting space isometrically with the regular languages. This space is incomplete, while its metric completion is naturally identified with the complete ultrametric space of all formal languages. Guarded language operators induce contractions on the automaton space, and their Picard iterates converge in the completion to the unique language fixed point, which is represented by a finite automaton exactly when it is regular. Motivated by structural input validation, we use this framework to construct depth-capped deterministic finite automata with certified finite-depth correctness. These automata provide efficient pre-filters for nested input structures, such as parenthesised SQL parameters, while avoiding the backtracking risks of regular-expression engines and the runtime overhead of full context-free parsers. We also outline a practical WAF pipeline combining learned grammar models, finite-state construction, and \(O(1)\)-memory runtime validation.