This paper addresses the dichotomy between the formalization of structural and the formalization of behavioral knowledge by means of semantically lifted programs, which explore an intuitive connection between programs and knowledge graphs. While knowledge graphs and ontologies are eminently useful to represent formal knowledge about a system's individuals and universals, programming languages are designed to describe the system's evolution. To address this dichotomy, we introduce a semantic lifting of the program states of an executing program into a knowledge graph, for an object-oriented programming language. The resulting graph is exposed as a semantic reflection layer within the programming language, allowing programmers to leverage knowledge of the application domain in their programs. In this paper, we formalize semantic lifting and semantic reflection for a small programming language, SMOL, explain the operational aspects of the language, and consider type correctness and virtualisation for runtime program queries through the semantic reflection layer. We illustrate semantic lifting and semantic reflection through a case study of geological modelling and discuss different applications of the technique. The language implementation is open source and available online.
翻译:本文通过语义提升程序(semantically lifted programs)探讨结构形式化与行为形式化之间的二元对立,揭示了程序与知识图谱之间的直观联系。知识图谱与本体在表示系统个体与共相的显式知识方面具有显著优势,而编程语言则被设计用于描述系统的演化过程。为应对这一二元性,我们针对面向对象编程语言提出了一种将执行中程序的程序状态语义提升至知识图谱的方法。生成的图谱以语义反射层的形式暴露于编程语言内部,使程序员能够在程序中利用应用领域的知识。本文针对小型编程语言SMOL形式化了语义提升与语义反射机制,阐述了该语言的操作语义,并讨论了通过语义反射层进行运行时程序查询的类型正确性与虚拟化问题。我们通过地质建模案例研究展示了语义提升与语义反射的实际应用,并探讨了该技术的多种应用场景。该语言实现为开源形式,可在线获取。