HOME

TheInfoList



OR:

In the field of
type theory In mathematics and theoretical computer science, a type theory is the formal presentation of a specific type system. Type theory is the academic study of type systems. Some type theories serve as alternatives to set theory as a foundation of ...
in
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, a quotient type is a
data type In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
which respects a user-defined equality relation. A quotient type defines an equivalence relation \equiv on elements of the type - for example, we might say that two values of the type Person are equivalent if they have the same name; formally p1

p2
if p1.name

p2.name
. In type theories which allow quotient types, an additional requirement is made that all operations must respect the equivalence between elements. For example, if f is a function on values of type Person, it must be the case that for two Persons p1 and p2, if p1

p2
then f(p1)

f(p2)
. Quotient types are part of a general class of types known as algebraic data types. In the early 1980s, quotient types were defined and implemented as part of the Nuprl proof assistant, in work led by Robert L. Constable and others. Quotient types have been studied in the context of Martin-Löf type theory, dependent type theory, higher-order logic, and homotopy type theory.


Definition

To define a quotient type, one typically provides a
data type In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
together with an equivalence relation on that type, for example, Person //

, where

is a user-defined equality relation. The elements of the quotient type are equivalence classes of elements of the original type. Quotient types can be used to define
modular arithmetic In mathematics, modular arithmetic is a system of arithmetic operations for integers, other than the usual ones from elementary arithmetic, where numbers "wrap around" when reaching a certain value, called the modulus. The modern approach to mo ...
. For example, if Integer is a data type of integers, \equiv_2 can be defined by saying that x \equiv_2 y if the difference x - y is even. We then form the type of integers modulo 2: :Integer // \equiv_2 The operations on integers, +, - can be proven to be well-defined on the new quotient type.


Variations

In type theories that lack quotient types, setoids (sets explicitly equipped with an equivalence relation) are often used instead of quotient types. However, unlike with setoids, many type theories may require a formal proof that any functions defined on quotient types are well-defined.


Properties

Quotient types are part of a general class of types known as algebraic data types. Just as product types and sum types are analogous to the cartesian product and disjoint union of abstract algebraic structures, quotient types reflect the concept of set-theoretic quotients, sets whose elements are partitioned into equivalence classes by a given equivalence relation on the set. Algebraic structures whose underlying set is a quotient are also termed quotients. Examples of such quotient structures include quotient sets, groups, rings, categories and, in topology, quotient spaces.


References


See also

* Algebraic data type * Product type * Setoid * Sum type {{data types Data types Type theory Composite data types