48 research outputs found
A Functional Abstraction of Typed Invocation Contexts
In their paper "A Functional Abstraction of Typed Contexts", Danvy and
Filinski show how to derive a monomorphic type system of the shift and reset
operators from a CPS semantics. In this paper, we show how this method scales
to Felleisen's control and prompt operators. Compared to shift and reset,
control and prompt exhibit a more dynamic behavior, in that they can manipulate
a trail of contexts surrounding the invocation of previously captured
continuations. Our key observation is that, by adopting a functional
representation of trails in the CPS semantics, we can derive a type system that
encodes all and only constraints imposed by the CPS semantics
Type‐Preserving CPS Translation of Σ and Π Types is Not Not Possible
International audienceDependently typed languages like Coq are used to specify and prove functional correctness of source programs,but what we ultimately need are guarantees about correctness of compiled code. By preserving dependenttypes through each compiler pass, we could preserve source-level specifications and correctness proofs intothe generated target-language programs. Unfortunately, type-preserving compilation of dependent types isnontrivial. In 2002, Barthe and Uustalu showed that type-preserving CPS is not possible for languages likeCoq. Specifically, they showed that for strong dependent pairs (Σ types), the standard typed call-by-name CPSis not type preserving. They further proved that for dependent case analysis on sums, a class of typed CPStranslations—including the standard translation—is not possible. In 2016, Morrisett noticed a similar problemwith the standard call-by-value CPS translation for dependent functions (Π types). In essence, the problem isthat the standard typed CPS translation by double-negation, in which computations are assigned types of theform (A → ⊥) → ⊥, disrupts the term/type equivalence that is used during type checking in a dependentlytyped language.In this paper, we prove that type-preserving CPS translation for dependently typed languages is not notpossible. We develop both call-by-name and call-by-value CPS translations from the Calculus of Constructionswith both Π and Σ types (CC) to a dependently typed target language, and prove type preservation andcompiler correctness of each translation. Our target language is CC extended with an additional equivalencerule and an additional typing rule, which we prove consistent by giving a model in the extensional Calculus ofConstructions. Our key observation is that we can use a CPS translation that employs answer-type polymorphism,where CPS-translated computations have type ∀α.(A → α) → α. This type justifies, by a free theorem,the new equality rule in our target language and allows us to recover the term/type equivalences that CPStranslation disrupts. Finally, we conjecture that our translation extends to dependent case analysis on sums,despite the impossibility result, and provide a proof sketch
A Functional Abstraction of Typed Invocation Contexts
In their paper "A Functional Abstraction of Typed Contexts", Danvy and
Filinski show how to derive a monomorphic type system of the shift and reset
operators from a CPS semantics. In this paper, we show how this method scales
to Felleisen's control and prompt operators. Compared to shift and reset,
control and prompt exhibit a more dynamic behavior, in that they can manipulate
a trail of contexts surrounding the invocation of previously captured
continuations. Our key observation is that, by adopting a functional
representation of trails in the CPS semantics, we can derive a type system that
encodes all and only constraints imposed by the CPS semantics
How Many Mutex Bugs Can a Simple Analysis Find in Go Programs?
In open-source software, it is known that there are many concurrency bugs. A previous study in Go revealed that a considerable number of such bugs are simple (for example, 9% of the bugs are the ones that forget to unlock a mutex,) through a manual program investigation. This paper tries to detect such bugs by applying a simple analysis to see how far such a tool can match the manual analysis. We built a simple intraprocedural control flow analysis in Go, and evaluated its performance concerning the open source programs with concurrency bugs reported in the previous study. Consequently, as for quality, the recall is good at 88%, and the precision is poor at 60%; as for analysis time, it can be finished within a practical amount of time (for example, 1 second per 5000 LoC)