arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2307.10034cs.DBcs.PL
收藏

现代JSON Schema的验证:形式化与复杂度

Validation of Modern JSON Schema: Formalization and Complexity

Lyes Attouche, Mohamed-Amine Baazizi, Dario Colazzo, Giorgio Ghelli, Carlo Sartiani, Stefanie Scherzinger

AI总结:

本研究首次形式化描述现代JSON Schema,证明其数据验证为PSPACE完全问题,根源在动态引用,并通过实验验证了动静态引用的渐近复杂度差异。

摘要:

JSON Schema是JSON数据事实上的标准模式语言。该语言历经多次小幅修订,但最新版本新增了两个特性——动态引用和依赖注解的验证,改变了其评估模型。“现代JSON Schema”指从Draft 2019-09起的所有版本,以这些新特性为标志,而“经典JSON Schema”指此前的版本。\n 这些“现代”新特性让模式语言变得相当难以理解,也引发了诸多关于其官方规范正确解读的讨论;因此我们承担了对其进行形式化的工作。在此过程中,我们还分析了现代JSON Schema中数据验证的复杂度,原本意在确认经典JSON Schema验证的PTIME(多项式时间)复杂度,却意外发现了截然不同的结论:原本预期应极为高效的数据验证过程,在加入现代JSON Schema的特性后,复杂度变为PSPACE(多项式空间)。\n 本文中,我们首次给出了现代JSON Schema的形式化描述,我们认为这是本研究的核心贡献。随后我们证明其数据验证问题是PSPACE完全的,且问题的根源在于动态引用,而非依赖注解的验证。我们研究了模式复杂度和数据复杂度,结果表明即使实例固定,该问题关于模式大小仍是PSPACE完全的;但当模式固定、仅实例大小可变时,问题处于PTIME复杂度类中。最后我们开展的实验显示,存在多类模式,即使模式规模很小,动态引用与静态引用之间的渐近复杂度差异也极为明显。

英文摘要:

JSON Schema is the de-facto standard schema language for JSON data. The language went through many minor revisions, but the most recent versions of the language added two novel features, dynamic references and annotation-dependent validation, that change the evaluation model. Modern JSON Schema is the name used to indicate all versions from Draft 2019-09, which are characterized by these new features, while Classical JSON Schema is used to indicate the previous versions. These new "modern" features make the schema language quite difficult to understand, and have generated many discussions about the correct interpretation of their official specifications; for this reason we undertook the task of their formalization. During this process, we also analyzed the complexity of data validation in Modern JSON Schema, with the idea of confirming the PTIME complexity of Classical JSON Schema validation, and we were surprised to discover a completely different truth: data validation, that is expected to be an extremely efficient process, acquires, with Modern JSON Schema features, a PSPACE complexity. In this paper, we give the first formal description of Modern JSON Schema, which we consider a central contribution of the work that we present here. We then prove that its data validation problem is PSPACE-complete. We prove that the origin of the problem lies in dynamic references, and not in annotation-dependent validation. We study the schema and data complexities, showing that the problem is PSPACE-complete with respect to the schema size even with a fixed instance, but is in PTIME when the schema is fixed and only the instance size is allowed to vary. Finally, we run experiments that show that there are families of schemas where the difference in asymptotic complexity between dynamic and static references is extremely visible, even with small schemas.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑