Definition - “for all”

A dependent function type is the type of functions whose result type depends on the input value. Given a type and a type family we construct a type of dependent functions:

A term of this type is a function , given its input , returns a term of Formally, if , then for any we will have

Type family and dependent function type.excalidraw

⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: ‘Decompress current Excalidraw file’. For more info check in plugin settings under ‘Saving’

Excalidraw Data

Text Elements

x

A

f

B

Type

Term

Input

Output

Input

Output

dependent function type

type family

dependent function

type of type family

Embedded Files

2ac32adecf2abd035aa737b4ec51d1c26392dca9:

a9cda798425d6d416ecaad0c4c7a8490e5c2f038:

44a822b01e15432d8b149bd8ac88743e96e3aafd:

72c67de3b382f9c9894dc502dc2ae3a6a373f82e:

6e48c148490b97fa98607c2c4420eb8ba2e0f8f3:

Link to original

Example 1

Suppose we have type and type family defined by and a function will returns a when given and a when given .

Example: fmax

we can define a dependent function that gives the “largest” element of the resulting type. We can let . Note that (see Definition of Fin(n))

Polymorphic

we can also use types as parameters, such constructed dependent functions are polymorphic over a give universe.

Example: id

Let is now a function that accept a type as input and return type as output.

we generally call as using -calculus which gives