Abstract

We give a denotational semantics for a region-based effect system that supports type abstraction in the sense that only externally visible effects need to be tracked: non-observable internal modifi- cations, such as the reorganisation of a search tree or lazy initialisation, can count as ‘pure’ or ‘read only’. This ‘fictional purity’ allows clients of a module to validate soundly more effect-based program equivalences than would be possible with previous semantics. Our semantics uses a novel variant of logical relations that maps types not merely to partial equivalence relations on values, as is commonly done, but rather to a proof-relevant generalisation thereof, namely setoids. The objects of a setoid establish that values inhabit semantic types, whilst its morphisms are understood as proofs of semantic equivalence. The transition to proof-relevance solves two awkward problems caused by na¨ıve use of existential quantification in Kripke logical relations, namely failure of admissibility and spurious functional dependencies.