Dependent type
In functional programming languages like Agda, ATS, Coq, F*, Epigram, Idris, and Lean, dependent types help reduce bugs by enabling the programmer to assign types that further restrain the set of possible implementations.For instance, a function that takes a positive integer(Note that this is different from polymorphism and generic programming, both of which include the type as an argument.)Deciding the equality of dependent types in a program may require computations.[1] In 1934, Haskell Curry noticed that the types used in typed lambda calculus, and in its combinatory logic counterpart, followed the same pattern as axioms in propositional logic.Going further, for every proof in the logic, there was a matching function (term) in the programming language.One of Curry's examples was the correspondence between simply typed lambda calculus and intuitionistic logic.Howard and de Bruijn extended lambda calculus to match this more powerful logic by creating types for dependent functions, which correspond to "for all", and dependent pairs, which correspond to "there exists".For this example, the dependent function type is typically written asis a constant function, the corresponding dependent product type is equivalent to an ordinary function type.The name 'Π-type' comes from the idea that these may be viewed as a Cartesian product of types.Π-types can also be understood as models of universal quantifiers.would be the type of a function which, given a natural number n, returns a tuple of real numbers of size n. The usual function space arises as a special case when the range type does not actually depend on the input.to be the type of unsigned integers from 0 to 255 (the ones that fit into 8 bits or 1 byte) and(The alternative notations are similar to that of Π types.)The dependent pair type captures the idea of an ordered pair where the type of the second term is dependent on the value of the first.is a constant function, then the dependent pair type becomes (is judgementally equal to) the product type, that is, an ordinary Cartesian productThe correspondence can be extended to existential quantification and dependent pairs: the propositionIn logic, this statement is codified by existential quantification:This proposition corresponds to the dependent pair type:Henk Barendregt developed the lambda cube as a means of classifying type systems along three axes.The eight corners of the resulting cube-shaped diagram each correspond to a type system, with simply typed lambda calculus in the least expressive corner, and calculus of constructions in the most expressive.The lambda cube is generalized further by pure type systems.In this theory the dependent product operator subsumes both theoperator of simply typed lambda calculus and theThe system corresponds to the calculus of constructions whose derivative, the calculus of inductive constructions is the underlying system of the Coq proof assistant.The Curry–Howard correspondence implies that types can be constructed that express arbitrarily complex mathematical properties.If the user can supply a constructive proof that a type is inhabited (i.e., that a value of that type exists) then a compiler can check the proof and convert it into executable computer code that computes the value by carrying out the construction.The proof checking feature makes dependently typed languages closely related to proof assistants.The code-generation aspect provides a powerful approach to formal program verification and proof-carrying code, since the code is derived directly from a mechanically verified mathematical proof.