请输入您要查询的字词:

 

单词 16DependentPairTypes
释义

1.6 Dependent pair types


Just as we generalized function types (§1.2 (http://planetmath.org/12functiontypes)) to dependent function types (§1.4 (http://planetmath.org/14dependentfunctiontypes)), it is often useful to generalize the product types from §1.5 (http://planetmath.org/15producttypes) to allow the type ofthe second componentPlanetmathPlanetmathPlanetmath of a pair to vary depending on the choice of the firstcomponent. This is called a dependent pair type, or Σ-type, because in set theoryMathworldPlanetmath itcorresponds to an indexed sum (in the sense of coproduct ordisjoint unionMathworldPlanetmath) over a given type.

Given a type A:𝒰 and a family B:A𝒰, the dependentpair type is written as (x:A)B(x):𝒰.Alternative notations are

(x:A)B(x)       (x:A)B(x)       (x:A),B(x).

Like other binding constructs such as λ-abstractions and Πs, Σs automatically scope over the rest of the expression unless delimited, so e.g. (x:A)B(x)×C(x) means (x:A)(B(x)×C(x)).

The way to construct elements of a dependent pair type is by pairing: we have(a,b):(x:A)B(x) given a:A and b:B(a).If B is constant, then the dependent pair type is theordinary cartesian product type:

((x:A)B)(A×B).

All the constructions on Σ-types arise as straightforward generalizationsPlanetmathPlanetmath of the ones for product types, with dependent functions often replacing non-dependent ones.

For instance, the recursion principlesays that to define a non-dependent function out of a Σ-typef:((x:A)B(x))C, we provide a functiong:(x:A)B(x)C, and then we can define f via the definingequation

f((a,b))܃g(a)(b).

For instance, we can derive the first projectionPlanetmathPlanetmath from a Σ-type:

𝗉𝗋1:((x:A)B(x))A.

by the defining equation

𝗉𝗋1((a,b))܃a.

However, since the type of the second component of a pair(a,b):(x:A)B(x)is B(a), the second projection must be a dependent function, whose type involves the first projection function:

𝗉𝗋2:(p:(x:A)B(x))B(𝗉𝗋1(p)).

Thus we need the inductionMathworldPlanetmath principlefor Σ-types (the “dependent eliminator”).This says that to construct a dependent function out of a Σ-type into a family C:((x:A)B(x))𝒰, we need a function

g:(a:A)b:B(a)C((a,b)).

We can then derive a function

f:(p:(x:A)B(x))C(p)

with defining equation

f((a,b))܃g(a)(b).

Applying this with C(p)܃B(𝗉𝗋1(p)), we can define𝗉𝗋2:(p:(x:A)B(x))B(𝗉𝗋1(p))with the obvious equation

𝗉𝗋2((a,b))܃b.

To convince ourselves that this is correct, we note that B(𝗉𝗋1((a,b)))B(a), using the defining equation for 𝗉𝗋1, andindeed b:B(a).

We can package the recursion and induction principles into the recursor for Σ:

𝗋𝖾𝖼(x:A)B(x):(C:𝒰)((x:A)B(x)C)((x:A)B(x))C

with the defining equation

𝗋𝖾𝖼(x:A)B(x)(C,g,(a,b))܃g(a)(b)

and the corresponding induction operator:

𝗂𝗇𝖽(x:A)B(x):(C:((x:A)B(x))𝒰)((a:A)b:B(a)C((a,b)))(p:(x:A)B(x))C(p)

with the defining equation

𝗂𝗇𝖽(x:A)B(x)(C,g,(a,b))܃g(a)(b).

As before, the recursor is the special case of inductionwhen the family C is constant.

As a further example, consider the following principle, where A and B are types and R:AB𝒰.

𝖺𝖼:((x:A)(y:B)R(x,y))((f:AB)(x:A)R(x,f(x)))

We may regard R as a “proof-relevant relationMathworldPlanetmath”between A and B, with R(a,b) the type of witnesses for relatedness of a:A and b:B.Then 𝖺𝖼 says intuitively that if we have a dependent function g assigning to every a:A a dependent pair (b,r) where b:B and r:R(a,b), then we have a function f:AB and a dependent function assigning to every a:A a witness that R(a,f(a)).Our intuition tells us that we can just split up the values of g into their components.Indeed, using the projections we have just defined, we can define:

𝖺𝖼(g)܃(λx.𝗉𝗋1(g(x)),λx.𝗉𝗋2(g(x))).

To verify that this is well-typed, note that if g:(x:A)(y:B)R(x,y), we have

λx.𝗉𝗋1(g(x)):AB,
λx.𝗉𝗋2(g(x)):(x:A)R(x,𝗉𝗋1(g(x))).

Moreover, the type (x:A)R(x,𝗉𝗋1(g(x))) is the result of substituting the function λx.𝗉𝗋1(g(x)) for f in the family being summed over in the codomain of 𝖺𝖼:

(x:A)R(x,𝗉𝗋1(g(x)))(λf.(x:A)R(x,f(x)))(λx.𝗉𝗋1(g(x))).

Thus, we have

(λx.𝗉𝗋1(g(x)),λx.𝗉𝗋2(g(x))):(f:AB)(x:A)R(x,f(x))

as required.

If we read Π as “for all” and Σ as “there exists”, then the type of the function 𝖺𝖼 expresses:if for all x:A there is a y:B such that R(x,y), then there is a function f:AB such that for all x:A we have R(x,f(x)).Since this sounds like a version of the axiom of choiceMathworldPlanetmath, the function 𝖺𝖼 has traditionally been called the type-theoretic axiom of choice, and as we have just shown, it can be proved directly from the rules of type theoryPlanetmathPlanetmath, rather than having to be taken as an axiom.However, note that no choice is actually involved, since the choices have already been given to us in the premiseMathworldPlanetmath: all we have to do is take it apart into two functions: one representing the choice and the other its correctness.In \\autorefsec:axiom-choice we will give another formulation of an “axiom of choice” which is closer to the usual one.

Dependent pair types are often used to define types of mathematical structures, which commonly consist of several dependent pieces of data.To take a simple example, suppose we want to define a magma to be a type A together with a binary operationMathworldPlanetmath m:AAA.The precise meaning of the phrase “together with” (and the synonymous “equipped with”) is that “a magma” is a pair (A,m) consisting of a type A:𝒰 and an operationMathworldPlanetmath m:AAA.Since the type AAA of the second component m of this pair depends on its first component A, such pairs belong to a dependent pair type.Thus, the definition “a magma is a type A together with a binary operation m:AAA” should be read as defining the type of magmas to be

𝖬𝖺𝗀𝗆𝖺܃(A:𝒰)(AAA).

Given a magma, we extract its underlying type (its “carrier”) with the first projection 𝗉𝗋1, and its operation with the second projection 𝗉𝗋2.Of course, structuresMathworldPlanetmath built from more than two pieces of data require iterated pair types, which may be only partially dependent; for instance the type of pointed magmas (magmas (A,m) equipped with a basepoint e:A) is

𝖯𝗈𝗂𝗇𝗍𝖾𝖽𝖬𝖺𝗀𝗆𝖺܃(A:𝒰)(AAA)×A.

We generally also want to impose axioms on such a structure, e.g. to make a pointed magma into a monoid or a group.This can also be done using Σ-types; see \\autorefsec:pat.

In the rest of the book, we will sometimes make definitions of this sort explicit, but eventually we trust the reader to translateMathworldPlanetmath them from English into Σ-types.We also generally follow the common mathematical practice of using the same letter for a structure of this sort and for its carrier (which amounts to leaving the appropriate projection function implicit in the notation): that is, we will speak of a magma A with its operation m:AAA.

Note that the canonical elements of 𝖯𝗈𝗂𝗇𝗍𝖾𝖽𝖬𝖺𝗀𝗆𝖺 are of the form (A,(m,e)) where A:𝒰, m:AAA, and e:A.Because of the frequency with which iterated Σ-types of this sort arise, we use the usual notation of ordered triples, quadruples and so on to stand for nested pairs (possibly dependent) associating to the right.That is, we have (x,y,z)܃(x,(y,z)) and (x,y,z,w)܃(x,(y,(z,w))), etc.

随便看

 

数学辞典收录了18232条数学词条,基本涵盖了常用数学知识及数学英语单词词组的翻译及用法,是数学学习的有利工具。

 

Copyright © 2000-2023 Newdu.com.com All Rights Reserved
更新时间:2025/5/4 18:59:10