# Pi Types

A Pi type is a type of (dependent) functions. If p_1, … p_n are named or unnamed parameters and B is a type, then \Pi p_1 … p_n -> B is also a type. If B does not refer to variables defined in the parameters, you can write A_1 -> … A_n -> B instead, where A_i are types of the parameters. If A_i has type \Type p_i h_i and B has type \Type p h, then the type of the Pi type is \Type p_max h, where p_max is the maximum of p_1, … p_n, and p. Note that the homotopy level of the Pi type is simply the homotopy level of the codomain.

An expression of the form \Pi p_1 … p_n -> B is equivalent to \Pi p_1 -> \Pi p_2 … p_n -> B. Moreover, if p_1 equals to (x_1 … x_k : A), then it is also equivalent to \Pi (x_1 : A) -> \Pi (x_2 … x_k : A) -> \Pi p_2 … p_n -> B.

A lambda parameter is either a variable or a named parameter. If p_1, … p_n is a sequence of lambda parameters and e is an expression of type E, then \lam p_1 … p_n => e is an expression which has type \Pi p_1 … p_n -> E. If some parameters do not have types, then they will be inferred by the typechecker.

If f is an expression of type \Pi (x : A) -> B and a is an expression of type A, then f a is an expression of type B[a/x].

An expression of the form (\lam x => b) a reduces to b[a/x].

An expression of the form \lam x => f x is equivalent to f if x is not free in f (eta equivalence for Pi types).

## Implicit lambdas

An implicit lambda is written as __. When this expression appears inside some other expression, the outer expression is replaced with a lambda and __ is replaced with the argument of this lambda. The outer expression is the closest ancestor of __ in which “it is possible to insert a lambda”. Lambda is never inserted in case arguments, anonymous class extensions, after \new, on the left of the function application, under projections, under \pi or \sigma, and under binary operators.

Examples:

• \case f __ \with { … } == \lam x => \case f x \with { … }
• f __.1 == f (\lam p => p.1)
• __ a + __ f g __ (h __ 0) == \lam x y z => x a + y f g z (\lam t => h t 0)
• + (f __) __ == \lam x => + (\lam y => f y) x
• __ -> \Sigma __ __ == \lam A B C => A -> \Sigma B C