Why type theory writes dependent pairs with a big sigma and dependent functions with a big pi
The algebra of dependent types (2025)
Tony Finch finally found the reason behind the notation: counting a type's inhabitants. Product types multiply, sum types add, and dependent pairs sum over each possible first value, so they get a big sigma. Dependent functions multiply across every argument, so they get a big pi. He also notes why "dependent sum" and "dependent product" are terms best avoided.
I have avoided the terms "dependent sum" and "dependent product", because they seem perfectly designed to cause confusion over whether I am talking about variants, records, or functions.
- rramadass
I think Dependent Types are easier to understand following Curry-Howard Correspondence (https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspon...) where the mapping to Logic is clearly spelled out.
1) Propositional Logic = Simple Types
2) Predicate Logic = Dependent Types (https://en.wikipedia.org/wiki/Dependent_type) where;
2.1) Existential Quantification = Σ-types (aka Dependent Sum/Pair) - https://en.wikipedia.org/wiki/Dependent_type#%CE%A3_type
2.2) Universal Quantification = Π-types (aka Dependent Product/Function) - https://en.wikipedia.org/wiki/Dependent_type#%CE%A0_type
Note that in order to understand the above you need to grasp "Type of Types" aka "Kinds"/"Universes".
The whole Typed Lambda Calculus to Calculus of Constructions (based on dependent types) is very nicely and succinctly explained by Helmut Brandl in his 100-page booklet Typed Lambda Calculus / Calculus of Constructions - https://hbr.github.io/Lambda-Calculus/index.html
- mananaysiempre
A couple of notes:
- There’s also the notation 0 for the empty (never, noreturn) type. In addition to matching the number of members, the notations 0 and 1 make sense also as units (neutral elements) of addition and multiplication respectively: 0 + A ≅ A + 0 ≅ A, 1 × A ≅ A × 1 ≅ A in a natural way[1]; and also 0 × A ≅ A × 0 ≅ 0.
- That a constant dependent sum is a product, and a constant dependent product is an exponential, is (undeniably confusing at first but) just[2] the naïve schoolbook definition that A × B = B added to itself A times and A^B = A multiplied by itself B times.
- That a constant dependent product is a function type is just the naïve definition that a function is a table of its values at each input (a tuple, with elements numbered by the possible inputs). A dependent function ( = dependent product), then, is the same thing but the allowable values in each cell of the table vary depending on the cell.
- That the function type is the exponential type is also part of common set-theory notation. For instance, 2^ℕ is a not-infrequent name for the set in the Cantor theorem (subsets of the naturals).
[1] As in, those are not literally the same type but are one-to-one in a single natural way. The word “natural” here has a surprisingly deep technical meaning but one that corresponds to the colloquial pretty well.
[2] “Just”, “simply”, etc. are as usual terms of art that mean that the statement feels very simple once you get it, and conversely that if it does not fe […]
- solomonb
This is fun. His array example `Σ len: usize . Array(Int, len)` is the list polynomial functor (1 + X + X² + ...) applied to ints.