Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
58 votes
Accepted

What can Idris not do by giving up Turing completeness?

Idris is Turing Complete! It does check for totality (termination when programming with data, productivity when programming with codata) but doesn't require that everything is total. Interestingly, ...
user avatar
48 votes
Accepted

What exactly is the semantic difference between set and type?

To understand the difference between sets and types, ones has to go back to pre-mathematical ideas of "collection" and "construction", and see how sets and types mathematize these. ...
user avatar
  • 28.1k
42 votes
Accepted

Dependent types vs refinement types

The main differences are along two dimensions -- in the underlying theory, and in how they can be used. Lets just focus on the latter. As a user, the "logic" of specifications in LiquidHaskell and ...
user avatar
39 votes
Accepted

Why is C's void type not analogous to the empty/bottom type?

In C, void is used for multiple unrelated things. Depending on what it's used for, its meaning may be a unit type, an empty type, or something else. When ...
user avatar
34 votes

What's the difference between a type and a kind?

Here, "values", "types", and "kinds" have formal meanings, so considering their common English usage or analogies to classifying automobiles will only get you so far. My answer pertains to the formal ...
user avatar
32 votes
Accepted

Why must a function with polymorphic type `forall t: Type, t->t` be the identity function?

The first thing to note is that this isn't necessarily true. For example, depending on the language a function with that type, besides being the identity function, could: 1) loop forever, 2) mutate ...
user avatar
27 votes
Accepted

Which research languages have a stronger typesystem than Haskell and why?

The question is somewhat problematic, since it relies on a subjective definition of "better." Dependently-typed languages such as Agda, Idris, and Coq have a stronger type system than ...
user avatar
  • 29.1k
25 votes

What is a brief but complete explanation of a pure/dependent type system?

Let's have a go. I'll not bother about Girard's paradox, because it distracts from the central ideas. I will need to introduce some presentational machinery about judgments and derivations and such. ...
user avatar
  • 546
25 votes
Accepted

Why does Coq include let-expressions in its core language

It is a common misconception that we can translate let-expresions to applications. The difference between let x : t := b in v ...
user avatar
  • 28.1k
23 votes
Accepted

What do we gain by having "dependent types"?

Expanding my comment: Dependent types can type more programs. "More" simply means that the set of programs typable with dependent types is a proper superset of the programs typable in the simply-typed ...
user avatar
21 votes
Accepted

Does the Y combinator contradict the Curry-Howard correspondence?

The original Curry-Howard correspondence is an isomorphism between intuitionistic propositional logic and the simply-typed lambda calculus. There are, of course, other Curry-Howard-like isomorphisms; ...
user avatar
  • 18.8k
21 votes
Accepted

Strict positivity

First a terminological explanation: negative and positive positions come from logic. They are about an assymetry in logical connectives: in $A \Rightarrow B$ the $A$ behaves differently from $B$. A ...
user avatar
  • 28.1k
21 votes

What's the difference between a type and a kind?

If you know about the difference between sets and classes in set theory, then it may help to think about the matter as $$\mathrm{type} : \mathrm{kind} = \mathrm{set} : \mathrm{class}.$$ If not, you ...
user avatar
  • 28.1k
19 votes
Accepted

Can I have a "dependent coproduct type"?

The dependent sum is a common generalization of both the cartesian product $A \times B$ and the coproduct $A + B$. It just so happens that the HoTT book introduces dependent sum by generalizing $A \...
user avatar
  • 28.1k
19 votes
Accepted

What does the leading turnstile operator mean?

On the left of the turnstile, you can find the local context, a finite list of assumptions on the types of the variables at hand. $$ x_1:T_1, \ldots, x_n:T_n \vdash e:T $$ Above, $n$ can be zero, ...
user avatar
  • 14.1k
18 votes
Accepted

Is there a non-trivial type which is equal to its own derivative?

Consider the finite multisets $\mathbf{Bag}\:X$. Its elements are given by $\{x_1,\ldots,x_n\}$ quotiented by permutations, so that $\{x_1,\ldots,x_n\}=\{x_{\pi 1},\ldots,x_{\pi n}\}$ for any $\pi\in\...
user avatar
  • 546
17 votes
Accepted

What is the use case for multi-type-parameter generics?

Some use cases for multiple type arguments include maps/dictionaries Map<K,V>, where you have one key parameter and one value parameter product types ...
user avatar
  • 14.1k
17 votes

Is there any use case for the bottom type as a function parameter type?

One of the defining properties of the $\bot$ or empty type is that there exists a function $\bot \to A$ for every type $A$. In fact, there exists a unique such function. It is therefore, fairly ...
user avatar
16 votes
Accepted

What is $Prop$ in the calculus of constructions?

In traditional Martin-Löf type theory there is no distinction between types and propositions. This goes under the slogan "propositions as types". But there are sometimes reasons for distinguishing ...
user avatar
  • 28.1k
16 votes
Accepted

What is induction-induction?

Supplemental 2016-10-03: I mixed up induction-induction and induction-recursion (not the first time I did that!). My apologies for the mess. I updated the answer to cover both. I find the ...
user avatar
  • 28.1k
16 votes
Accepted

Is there a difference between type safety and type soundness?

Type safety and type soundness are synonyms in most theoretical work. Type soundness is often formulated with respect to an operational semantics as (type) preservation and progress. Preservation ...
user avatar
15 votes
Accepted

Reference request: Category theory as it applies to type systems

Category theory is not necessary to understand programming languages, it's not even necessary to do advanced research on programming languages. Most programming language people don't know (much) ...
user avatar
15 votes
Accepted

Why product type is a dependent SUM?

Let's do products first. The usual cartesian product $A \times B$ is also called a binary product because we are making a product of two sets. We could make a ternary product $A \times B \times C$. ...
user avatar
  • 28.1k
15 votes

Why must a function with polymorphic type `forall t: Type, t->t` be the identity function?

The proof of the claim is quite complex, but if that's what you really want, you can check out Reynolds' original paper on the topic. The key idea is that it holds for parametrically polymorphic ...
user avatar
  • 29.1k
15 votes

What do the ∀ and ∃ symbols mean in the Axiom of Choice?

$\forall$ reads as "for all", and $\exists$ reads as "there exists". So, in english we have $$\text{"if }\underbrace{\text{for all $x$}}_{\forall x^\sigma}\text{ }\underbrace{\text{exists a $y$}}_{\...
user avatar
  • 290
14 votes
Accepted

Question on the "Tutorial implementation of dependently typed lambda calculus"

$\mathsf{id}$ and $\mathsf{const}$ are not variables of the calculus, but syntactic sugar for $\lambda x \rightarrow x$ and $\lambda x \rightarrow \lambda y \rightarrow x$ respectively. This is stated ...
user avatar
13 votes
Accepted

Proving a sorting operation in type system

Yes, it is possible to express a precise type for a sorting routine, such that any function having that type must indeed sort the input list. While there might be a more advanced and elegant solution,...
user avatar
  • 14.1k
13 votes
Accepted

What do the ∀ and ∃ symbols mean in the Axiom of Choice?

The symbols are quantifiers. They bind a new variable name to the symbolic logic statements. ∃ reads as there exists. ∀ reads for all so the first part of the statement would be read as: forall x (...
user avatar
  • 619
12 votes
Accepted

Universal/existential quantification?

It helps to remember that $\forall$ (or $\Pi$ as you sometimes see) is a type. It's generalizing $\to$. So while it makes perfect sense to say $(\lambda x : A. M)\ N$, it doesn't make sense to say $(\...
user avatar
12 votes
Accepted

"Minimal" intuitionistic type theory?

To elaborate on gallais' clarifications, a type theory with impredicative Prop, and dependent types, can be seen as some subsystem of the calculus of constructions, typically close to Church's type ...
user avatar
  • 7,744

Only top scored, non community-wiki answers of a minimum length are eligible