Semantic Predicate Types and Approximation for Class-based Object Oriented Programming
We apply the principles of the intersection type discipline to the study of class-based object oriented programs and; our work follows from a similar approach (in the context of Abadi and Cardelli’s Varsigma-object calculus) taken by van Bakel and de’Liguoro. We define an extension of Featherweight Java, FJc and present a predicate system which we show to be sound and expressive. We also show that our system provides a semantic underpinning for the object oriented paradigm by generalising the concept of approximant from the Lambda Calculus and demonstrating an approximation result: all expressions to which we can assign a predicate have an approximant that satisfies the same predicate. Crucial to this result is the notion of predicate language, which associates a family of predicates with a class.
💡 Research Summary
The paper introduces a novel predicate system for a class‑based object‑oriented language by extending Featherweight Java (FJ) with concepts from intersection type theory. The authors define an extended calculus called Predicate Featherweight Java (pFJ), which retains the core syntax of FJ (class declarations, fields, methods, object creation) while adding explicit support for the null literal and field assignment. Constructors and casts are omitted to keep the system sound and simpler; upcasts are handled by subsumption rules.
Predicates are introduced as semantic descriptors of the behavior that an object can exhibit. The grammar distinguishes top (⊤), null (N), object predicates σ (a set of member predicates), and member predicates τ. A member predicate for a field is simply a predicate ν, while for a method it has the form ψ :: φ → ν, indicating the required predicate ψ on the receiver, predicates φ on the arguments, and the predicate ν on the result. This mirrors the intersection‑type idea of assigning multiple, possibly incomparable types to a term, now applied to the operations that can be performed on an object.
A key notion is the predicate language L(C) associated with each class C. L(C) enumerates all predicates that objects of class C are allowed to possess. Predicate assignment rules are constrained to produce predicates that belong to the appropriate L(C), ensuring that the system respects the class hierarchy and inheritance.
The authors prove two fundamental meta‑theoretical results. First, a subject‑reduction theorem for both the type system and the predicate system: if an expression e has type C (or predicate σ) and reduces to e′, then e′ retains the same type (or predicate). This guarantees that evaluation does not invalidate the static information. Second, an approximation theorem: any expression that can be assigned a non‑trivial predicate also has a finite approximant—a finite rooted segment of its head‑normal form—that satisfies the same predicate. The proof relies on the predicate language and on the fact that a non‑trivial predicate guarantees the existence of a head‑normal form.
These results give the predicate system a solid semantic foundation. Because predicates describe concrete operations (field reads, writes, method calls) and their required pre‑ and post‑conditions, they can be used for static analyses that go beyond traditional type checking. For instance, a method call that requires a receiver predicate different from N will be rejected if the receiver might be null, thus detecting potential null‑pointer dereferences at compile time. Similarly, if every method’s result predicate guarantees termination (e.g., by not containing recursive self‑references), the system can certify termination of whole programs. The authors also discuss how the framework could be extended to dead‑code detection, effect systems, and strictness analysis.
The system is inherently semi‑decidable, as unrestricted intersection types make type inference undecidable. The paper acknowledges this and suggests practical restrictions (e.g., limiting the depth of intersections or the shape of predicates) to obtain a decidable fragment suitable for implementation, while preserving the core theorems.
In summary, the work provides a rigorous, semantics‑driven predicate calculus for class‑based OO languages, bridging the gap between type theory and operational behavior. By proving subject reduction and an approximation property, it establishes a foundation for expressive static analyses such as null‑pointer checking and termination proving, and opens avenues for further research on type‑based abstract interpretation of object‑oriented programs.
Comments & Academic Discussion
Loading comments...
Leave a Comment