485 research outputs found
A Syntactic Model of Mutation and Aliasing
Traditionally, semantic models of imperative languages use an auxiliary
structure which mimics memory. In this way, ownership and other encapsulation
properties need to be reconstructed from the graph structure of such global
memory. We present an alternative "syntactic" model where memory is encoded as
part of the program rather than as a separate resource. This means that
execution can be modelled by just rewriting source code terms, as in semantic
models for functional programs. Formally, this is achieved by the block
construct, introducing local variable declarations, which play the role of
memory when their initializing expressions have been evaluated. In this way, we
obtain a language semantics which directly represents at the syntactic level
constraints on aliasing, allowing simpler reasoning about related properties.
To illustrate this advantage, we consider the issue, widely studied in the
literature, of characterizing an isolated portion of memory, which cannot be
reached through external references. In the syntactic model, closed block
values, called "capsules", provide a simple representation of isolated portions
of memory, and capsules can be safely moved to another location in the memory,
without introducing sharing, by means of "affine' variables. We prove that the
syntactic model can be encoded in the conventional one, hence efficiently
implemented.Comment: In Proceedings DCM 2018 and ITRS 2018 , arXiv:1904.0956
Mutation, Aliasing, Viewpoints, Modular Reasoning, and Weak Behavioral Subtyping
Existing work on behavioral subtyping either ignores aliasing or restricts the behavior of additional methods in a subtype and only allows one to use invariants and history constraints in reasoning. This prevents many useful subtype relationships; for example, a type with immutable objects (e.g., immutable sequences), cannot have a behavioral subtype with mutable objects (e.g., mutable arrays). Furthermore, the associated reasoning principle is not very useful, since one cannot use the pre- and postconditions of methods. Weak behavioral subtyping permits more behavioral subtype relationships, does not restrict the behavior of additional methods in subtypes, and allows the use of pre- and postconditions in reasoning. The only cost is the need to restrict aliases so that objects cannot be manipulated through the view of more than one type
Latte: Lightweight Aliasing Tracking for Java
Many existing systems track aliasing and uniqueness, each with their own
trade-off between expressiveness and developer effort. We propose Latte, a new
approach that aims to minimize both the amount of annotations and the
complexity of invariants necessary for reasoning about aliasing in an
object-oriented language with mutation. Our approach only requires annotations
for parameters and fields, while annotations for local variables are inferred.
Furthermore, it relaxes uniqueness to allow aliasing among local variables, as
long as this aliasing can be precisely determined. This enables support for
destructive reads without changes to the language or its run-time semantics.
Despite this simplicity, we show how this design can still be used for tracking
uniqueness and aliasing in a local sequential setting, with practical
applications, such as modeling a stack
Forcing Behavioral Subtyping Through Specification Inheritance
A common change to object-oriented software is to add a new type of data that is a subtype of some existing type in the program. However, due to message passing unchanged parts of the program may now call operations of the new type. To avoid reverification of unchanged code, such operations should have specifications that are related to the specifications of the appropriate operations in their supertypes. This paper presents a specification technique that uses inheritance of specifications to force the appropriate behavior on the subtype objects. This technique is simple, requires little effort by the specifier, and avoids reverification of unchanged code. We present two notions of such behavioral subtyping, one of which is new. We show how to use these techniques to specify examples in C++
- …