Towards the Future: Bring Program Correctness back to the focus

Chongyi Yuan, Lijie Wen, Xiongliang YanarXiv 2022 · DOI

Abstract

The pursuit of absolute program correctness has long been sidelined in software engineering due to the mathematical complexity and lack of scalability of traditional formal methods. This paper proposes OESPA (Semantic Oriented Theory of Programming), a novel formal framework that redefines program variables and introduces a "semantic calculus" to automate the derivation of program meaning. By treating variables as "two-facet objects" and utilizing keyword-free mathematical predicates, OESPA provides a pathway to replace manual proofs with automated computational tools, potentially restoring correctness as a central focus of the software lifecycle.

Introduction

For decades, the software industry has prioritized "reliability" and "robustness" over "correctness." This shift was largely pragmatic; traditional methods like Hoare Logic or Denotational Semantics proved too cumbersome for large-scale modern programs. A fundamental issue is the logical ambiguity of variables: the programming assignment $x = x + 1$ is a mathematical contradiction. Traditional logic requires auxiliary constants to track state changes, making automated analysis difficult. OESPA aims to bridge this gap by aligning the physical reality of memory with logical analysis.

Methodology

The OESPA framework is built upon the ARM (Abstraction, Representation, Method) meta-method, consisting of three core components:

  1. Operation Expression (OE): A computation model where variables are "two-facet objects"—representing both a physical memory location and a mathematical value. New notation distinguishes between writing to a variable ($\bar{v}$), reading its post-operation value ($\underline{v}$), and reading its pre-operation value ($\tilde{v}$).
  2. Conditional Semantic Predicates (CSP): Branching logic (if-then-else) is represented using exclusive-OR ($\oplus$) logic, creating "keyword-free" formulas that are more amenable to algorithmic processing.
  3. Semantics Calculus (SC): A set of five reduction rules—Completion, Relay, Associative, Substitution, and Distribution—used to simplify raw "semantic formulas" into clean "semantic predicates."
The OESPA Semantics Calculus process, showing the reduction of operation expressions into a final semantic predicate.

Key Insights and Results

A primary innovation of OESPA is the "two-facet" variable, which allows initial and final states to coexist in a single formula without ambiguity. Unlike the sequential nature of Hoare Logic's weakest preconditions, OESPA's calculus supports parallel reduction, significantly enhancing the performance potential for automated tools.

The framework was evaluated against classic benchmarks, including sorting algorithms, recursive functions (Factorial, Fibonacci), and complex memory indirection (C pointers). Key findings include:

  • Recursion can be reduced to closed-form mathematical expressions via induction.
  • C Pointers are accurately modeled by distinguishing between hardware addresses and compiler-defined variable names.
  • Complex tasks, such as the Hanoi Tower, can be simplified into binary tree structures that highlight sub-task independence and parallelizability.

Conclusion

OESPA establishes a foundational theory for the automatic computation of program semantics. While currently a theoretical framework, it provides the mathematical machinery necessary to integrate program correctness into standard software development. Future work will focus on expanding support for high-level languages like Java and Python and developing the automated tools (compilers and verifiers) required for industry adoption.

Summary updated

Abstract

Program correctness used to be the main concern of computer software in the early days when formal semantics was a hot topic. But, the word "correct" was afterwards replaced by reliable, robust and trustworthy etc., a tradeoff situation then. This is not because correctness is no longer important, but because people found no way to get through in this direction. The tradeoff has led software engineers to focus on techniques and testing tools. Rapid development of software engineering has now reached a peak and programmers are now working freely without worrying too much about bugs, since bugs are not avoidable anyway. Is it meaningful to talk about program correctness today? Our answer is yes. It is the time to seriously consider correctness again, before it is too late, to prepare for the future. Future generation computer systems should be correct, both syntactically (statically) and semantically (dynamically). The book "OESPA: Semantic Oriented Theory of Programming" (2019) by the first author has opened a new direction for semantic study. Theoretically speaking, it is possible now, based on OESPA, to compute program semantics from program text so that program correctness could be proved. But, semantic computations and correctness proving cannot be done by hand when the size of a program is big. Automatic tools are necessary. This paper tries to lay a foundation for developing needed auto tools, so that OESPA is enriched to serve future need. To this end, a new concept named conditional semantic predicate is proposed. Concepts in OESPA, including semantic functions, semantic predicates, semantic formulas and semantic calculus, are re-represented in accordance. Such re-introduction is necessary since the book is the only publication on semantic calculus so far. The new version of semantic calculus illustrates how semantics auto-computation would be carried out.
BibTeX
@misc{yuan2022towards,
  author = {Chongyi Yuan and Lijie Wen and Xiongliang Yan},
  title = {{Towards the Future: Bring Program Correctness back to the focus}},
  year = {2022},
  eprint = {2203.15653},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.15653},
}
Figure