Content deleted Content added
clean up, Removed: Category:Articles lacking sources (Erik9bot), using AWB |
No edit summary |
||
Line 4:
For example, ''x'' ∈ {1,2,3} (where ''x'' is the value of the [[Variable (programming)|variable]] ''x'' after an operation) could be refined to ''x'' ∈ {1,2}, then ''x'' ∈ {1}, and implemented as ''x'' := 1. Implementations of ''x'' := 2 and ''x'' := 3 would be equally acceptable in this case, using a different route for the refinement. However, we must be careful not to refine to ''x'' ∈ {} (equivalent to ''false'') since this is unimplementable; it is impossible to select a [[Element (mathematics)|member]] from the [[empty set]].
In [[type theory]], a '''refinement type''' is a type endowed with a predicate which is assumed to hold for any element of the refined type. Refinement types can express [[precondition]]s when used as [[function argument]]s or [[postcondition]]s when used as [[return type]]s: for instance, the type of a function which accepts natural numbers and returns natural numbers greater than 5 may be written as <math>f: \mathbb{N} \rarr \{n: \mathbb{N} | n > 5\}</math>. Refinement types are thus related to [[behavioral subtyping]].
The term [[Reification (computer science)|reification]] is also sometimes used (coined by [[Cliff Jones (computer scientist)|Cliff Jones]]). [[Retrenchment (computing)|Retrenchment]] is an alternative technique when formal refinement is not possible. The opposite of refinement is [[Abstraction (computer science)|abstraction]].
|