Memoized Derivatives for Fast Filtering and Schema Validation of Semi-Structured Data
We present a high-performance filtering and schema-validation algorithm based on Brzozowski’s derivatives, extended to regular hedge grammars for semi-structured data. Our algorithm inherits the expressiveness of regular hedge grammars to support a wide range of schema languages and serialization formats, such as JSON Schema, RELAX NG for XML, and Protocol Buffers. High performance is achieved by refactoring the derivative algorithm to make it more amenable to memoization of hedges. We verify in Lean that our memoization technique is correct: our memoized filtering and validation algorithm is equivalent to the denotational semantics of regular hedge grammars. This is the first proof of correctness in an interactive theorem prover of a derivative algorithm for regular hedge grammars or schema languages. We combine the memoization technique with the fusion of the parsing and derivative algorithms to avoid creating intermediate parsing data structures. Benchmarking is done on an implementation in Go against several other JSON Schema implementations. We end up with the fastest library in the filtering use case when considering median latency, providing evidence that derivatives are a competitive approach for validation, even for semi-structured data.
Authors
- Brink van der Merwe (ORCID: https://orcid.org/0000-0001-5010-9934)
- Walter Schulze
- Christiaan Maasdorp (ORCID: https://orcid.org/0000-0002-9248-4756)
- Paul Cadman (ORCID: https://orcid.org/0009-0002-5034-3514)
Institutions
- Stellenbosch University (ZA)
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-07-02
- DOI
- https://doi.org/10.5281/zenodo.21134537
- Primary Topic
- Advanced Database Systems and Queries
- Type
- preprint