PLLOApr 7

Semantically Reflected Programs

arXiv:2509.0331822.0h-index: 28Has Code
AI Analysis

This work addresses the problem of integrating domain knowledge into programming for developers, but it is incremental as it builds on existing ideas of reflection and knowledge representation.

The paper tackles the gap between representing structural knowledge (via knowledge graphs) and behavioral knowledge (via programming languages) by introducing semantic lifting, which maps program states to a knowledge graph, and semantic reflection, which integrates this graph into the programming language to allow domain knowledge usage in programs. It formalizes these concepts for a small language called SMOL, demonstrates them in a geological modeling case study, and provides an open-source implementation.

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.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes