Refinement Types and Logical Subtyping
Compare predicates over the same base value and derive the obligation for passing a refined expression to a function.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
A type restricts a value by a formula
Write \(\{v:\mathrm{Int}\mid 0\le v<10\}\) for integers within the indicated bound. It is a subtype of \(\{v:\mathrm{Int}\mid v\ge0\}\) because its predicate implies the second. The reverse implication fails at \(v=10\). A use of the refined value gains a logical fact without changing its runtime integer representation.
Path information can justify the use
Inside a branch with \(0\le i<n\), a checker can pass \(i\) to an abstract indexing operation requiring precisely that range for length \(n\). Outside the guard it needs another premise. The verification problem is context plus source predicate implying the target predicate. A decidable fragment trades expressiveness against predictable checking. SMT can discharge the implication by ruling out a countermodel. Refinement type systems develop inference, abstraction and polymorphic cases.[1][2]