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:
- 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}$).
- 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.
- 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."
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