434 research outputs found
A Type System for First-Class Layers with Inheritance, Subtyping, and Swapping
Context-Oriented Programming (COP) is a programming paradigm to encourage
modularization of context-dependent software. Key features of COP are
layers---modules to describe context-dependent behavioral variations of a
software system---and their dynamic activation, which can modify the behavior
of multiple objects that have already been instantiated. Typechecking programs
written in a COP language is difficult because the activation of a layer can
even change objects' interfaces. Inoue et al. have informally discussed how to
make JCop, an extension of Java for COP by Appeltauer et al., type-safe.
In this article, we formalize a small COP language called ContextFJ
with its operational semantics and type system and show its type soundness. The
language models main features of the type-safe version of JCop, including
dynamically activated first-class layers, inheritance of layer definitions,
layer subtyping, and layer swapping
A Logical Foundation for Environment Classifiers
Taha and Nielsen have developed a multi-stage calculus {\lambda}{\alpha} with
a sound type system using the notion of environment classifiers. They are
special identifiers, with which code fragments and variable declarations are
annotated, and their scoping mechanism is used to ensure statically that
certain code fragments are closed and safely runnable. In this paper, we
investigate the Curry-Howard isomorphism for environment classifiers by
developing a typed {\lambda}-calculus {\lambda}|>. It corresponds to
multi-modal logic that allows quantification by transition variables---a
counterpart of classifiers---which range over (possibly empty) sequences of
labeled transitions between possible worlds. This interpretation will reduce
the "run" construct---which has a special typing rule in
{\lambda}{\alpha}---and embedding of closed code into other code fragments of
different stages---which would be only realized by the cross-stage persistence
operator in {\lambda}{\alpha}---to merely a special case of classifier
application. {\lambda}|> enjoys not only basic properties including subject
reduction, confluence, and strong normalization but also an important property
as a multi-stage calculus: time-ordered normalization of full reduction. Then,
we develop a big-step evaluation semantics for an ML-like language based on
{\lambda}|> with its type system and prove that the evaluation of a well-typed
{\lambda}|> program is properly staged. We also identify a fragment of the
language, where erasure evaluation is possible. Finally, we show that the proof
system augmented with a classical axiom is sound and complete with respect to a
Kripke semantics of the logic
A dependently typed multi-stage calculus
Programming Languages and Systems: 17th Asian Symposium, APLAS 2019, Nusa Dua, Bali, Indonesia, December 1–4, 2019. Part of the Lecture Notes in Computer Science book series (LNCS, volume 11893). Also part of the Programming and Software Engineering book sub series (LNPSE, volume 11893).We study a dependently typed extension of a multi-stage programming language à la MetaOCaml, which supports quasi-quotation and cross-stage persistence for manipulation of code fragments as first-class values and an evaluation construct for execution of programs dynamically generated by this code manipulation. Dependent types are expected to bring to multi-stage programming enforcement of strong invariant—beyond simple type safety—on the behavior of dynamically generated code. An extension is, however, not trivial because such a type system would have to take stages of types—roughly speaking, the number of surrounding quotations—into account. To rigorously study properties of such an extension, we develop λMD, which is an extension of Hanada and Igarashi’s typed calculus λ▹% with dependent types, and prove its properties including preservation, confluence, strong normalization for full reduction, and progress for staged reduction. Motivated by code generators that generate code whose type depends on a value from outside of the quotations, we argue the significance of cross-stage persistence in dependently typed multi-stage programming and certain type equivalences that are not directly derived from reduction rules
Type-based Qubit Allocation for a First-Order Quantum Programming Language
Qubit allocation is a process to assign physical qubits to logical qubits in
a quantum program. Since some quantum computers have connectivity constraints
on applications of two-qubit operations, it is mainly concerned with finding an
assignment and inserting instructions to satisfy the connectivity constraints.
Many methods have been proposed for the qubit allocation problem for low-level
quantum programs. This paper presents a type-based framework of qubit
allocation for a quantum programming language with first-order functions. In
our framework, the connectivity constraints are expressed by a simple graph of
qubits called a coupling graph. We formalize (1) the source language, whose
type system verifies that the number of qubits required for a given program to
run does not exceed the number of nodes of the coupling graph, (2) the target
language, whose qualified type system verifies that a well-typed program
satisfies the connectivity constraints, and (3) an algorithm to translate a
source program into a target program. We prove that both languages are
type-safe and that the translation algorithm is type preserving.Comment: 15 pages + appendix, 10 figures, presented at PPL2022 (Japanese
domestic conference
On Inner Classes
AbstractInner classes in object-oriented languages play a role similar to nested function definitions in functional languages, allowing an object to export other objects that have direct access to its own methods and instance variables. However, the similarity is deceptive: a close look at inner classes reveals significant subtleties arising from their interactions with inheritance. The goal of this work is a precise understanding of the essential features of inner classes; our object of study is a fragment of Java with inner classes and inheritance (and almost nothing else). We begin by giving a direct reduction semantics for this language. We then give an alternative semantics by translation into a yet smaller language with only top-level classes, closely following Java's Inner Classes Specification. We prove that the two semantics coincide, in the sense that translation commutes with reduction, and that both are type-safe
Signature Restriction for Polymorphic Algebraic Effects
The naive combination of polymorphic effects and polymorphic type assignment
has been well known to break type safety. Existing approaches to this problem
are classified into two groups: one for restricting how effects are triggered
and the other for restricting how they are implemented. This work explores a
new approach to ensuring the safety of polymorphic effects in polymorphic type
assignment. A novelty of our work lies in finding a restriction on effect
interfaces. To formalize our idea, we employ algebraic effects and handlers,
where an effect interface is given by a set of operations coupled with type
signatures. We propose signature restriction, a new notion to restrict the type
signatures of operations, and show that signature restriction is sufficient to
ensure type safety of an effectful language equipped with unrestricted
polymorphic type assignment. We also develop a type-and-effect system to enable
the use of both operations that satisfy and do not satisfy the signature
restriction in a single program
- …