Might anyone be able to explain the difference between:Algebraic Datatypes (which I am fairly familiar with)Generalized Algebraic Datatypes (what makes them generalized?)Inductive Types (e.g. Coq)(Especially inductive types.) Thank you.
What's the difference between ADTs, GADTs, and inductive types?
lo.logic;pl.programming languages;type theory;dependent type
Algebraic data types let you define types recursively. Concretely, suppose we have the datatype$$   \mathsf{data\;list = Nil \;\;|\;\; Cons\;of\;\mathbb{N} \times list} $$What this means is that $\mathsf{list}$ is the smallest set generated by the $\mathsf{Nil}$ and $\mathsf{Cons}$ operators. We can formalize this by defining the operator $F(X)$$$    F(X) == \{ \mathsf{Nil} \} \cup \{ \mathsf{Cons}(n, x) \;|\; n \in \mathbb{N} \land x \in X \} $$and then defining $\mathsf{list}$ as $$    \mathsf{list} = \bigcup_{i \in \mathbb{N}} F^i(\emptyset) $$A generalized ADT is what we get when define a type operator recursively. For example, we might define the following type constructor:$$    \mathsf{bush}\;a = \mathsf{Leaf\;of\;}a \;\;|\;\; \mathsf{Nest\;of\;bush}(a \times a) $$This type means that an element of $\mathsf{bush\;}a$ is a tuple of $a$s of length $2^n$ for some $n$, since each time we go into the $\mathsf{Nest}$ constructor the type argument is paired with itself. So we can define the operator we want to take a fixed point of as:$$   F(R) = \lambda X.\; \{ \mathsf{Leaf}(x) \;|\; x \in X\} \cup \{ \mathsf{Nest}(v) \;|\; v \in R(X) \} $$An inductive type in Coq is essentially a GADT, where the indexes of the type operator are not restricted to other types (as in, for example, Haskell), but can also be indexed by values of the type theory. This lets you give types for length-indexed lists, and so on.