In type theory and logic, predicativity is the property that quantifications do not create objects of the same class as the variable being quantified over. So one cannot quantify over formulas and get a formula. Instead, one gets a formula’ — some class distinct from formulas. In type theory, predicative quantification means that an expression which is quantifying over types is not itself a type (Haskell works like this, which surprised me). Often (for example, in both Coq and Agda), one sees a countable hierarchy of type universes: a quantification over Type(x) lives in universe Type(x+1). Impredicativity allows one to stay at the same level. So in Coq, which has an impredicative universe called Prop at the bottom of the universe hierarchy, quantifications over Prop are still in Prop. From a type theory perspective, impredicative polymorphism is a quantification of types which still gives you a type, of the same kind that can be used for instantiating such quantifications. Indeed, it is the possibility of instantiating a quantifier with the entire quantified formula itself that makes analysis of impredicativity challenging. Challenging, but well understood: Girard discovered the way to prove normalization in the presence of impredicative polymorphism for his System F (see his co-authored book Proofs and Types).
Forget squabbles over comment characters (I do think I prefer Haskell/Agda’s now over OCaml’s — sorry!): people can really tangle over predicativity versus impredicativity. I have heard second-hand that a well-known type theorist is against impredicativity because he distrusts a trick that can only be used once. This refers to the fact that we cannot have a layered language with impredicativity in two layers: Girard proved this leads to inconsistency, with his analysis of System U; see the discussion by Coquand here. This is why in Luo’s Extended Calculus of Constructions (ECC), which is part of the type theory of Coq, only the base level of the universe hierarchy is impredicative, and the other levels are predicative.
I have to say I find this criticism, that we should distrust tricks that can only be used once, unconvincing. For impredicativity is a heck of a trick. The best part is that it enables lambda encodings. I am on a personal quest to rehabilitate lambda encodings, and I am working on new type theories that support dependently typed programming and proving with lambda encodings. A first step along these lines is my work with Peng Fu on self types, which you can read about here. This is not the place to go into all the details, but impredicativity is absolutely essential. With only predicative quantification, there really is no way to make lambda encodings practical.
Furthermore, if impredicativity is the trick that can only be used once (and hey, let’s use it), predicativity is the trick you have to keep using again and again and again. To avoid repeating code and datatype definitions at each level of the hierarchy (which one quickly finds will be needed for a lot of practical examples), we have to resort to level polymorphism. Now a level-polymorphic type is not in any level we can access. Why not just extend to higher ordinals? Oh boy. And of course, we have to solve level constraints that the type system imposes. This complicates type checking.
So predicativity is out for me, including ECC-style predicative hierarchies over impredicative base levels. But impredicativity is not getting off so easily. Not for funny philosophical reasons or because we have to use it carefully — and we are treading the line here, as the more expressive we make our logic the closer we skirt the edge of inconsistency — but because it too has its own peculiar restrictions. I have just been learning about these, and indeed, they are the impetus for writing this post. Did you know that you cannot perform large eliminations on so-called impredicative datatypes in Coq? And that these datatypes are the reason that Coq enforces strict positivity for datatype declarations (the datatype cannot be used to the left of an arrow, even if to the left of an even number of arrows, in the type for an argument to a constructor of that datatype)? Well, if you are reading this post you probably did. But I did not. The counterexample is from a 1988 conference paper by Coquand and Paulin-Mohring. Their presentation is a bit hard to read through for me, anyway, but thankfully Vilhelm Sjöberg transcribed it into Coq, with helpful comments, here.
Reading through this example has been challenging, not just because it is tricky and I still did not manage to get a great intuitive grasp of how it works. But also because I have been worried it might apply to the type theory I am developing as the next step in the work on dependently typed lambda encodings. And that would be very troubling, as I have a 20-page proof of consistency of that system! Did I mess up my proof? What features of ECC + inductive types are actually needed for that example of Coquand and Paulin-Mohring’s? As Vilhelm wrote it, the example does use the predicative hierarchy of ECC, not just Prop. I am not 100% convinced that it could not be carried out in Prop alone, though.
After much puzzling, I think I understand why this example would not affect the system I am working on, which allows impredicative nonstrictly positive datatypes, and for which I believe I will soon have an extension with large eliminations. This sounds miraculous, because Coq forbids nonstrictly positive datatypes, and also forbids large eliminations of impredicative datatypes. I am saying you could have both simultaneously and be consistent. That must be wrong, right? Well, wrong (maybe). The difference is that I am working in a Curry-style type theory, similar to the Implicit Calculus of Constructions (ICC) of Miquel (with several additional features for dependently typed lambda encodings). As an aside, while I have the highest admiration for Miquel’s work, his system has added several strange typing rules that prevent a reasonable metatheory and violate a number of aesthetic guidelines for type theory. My system does not follow Miquel on those points — though we do not yet have the definable subtyping which is the most intriguing practical point of ICC, albeit to my knowledge not yet capitalized on in any system or even other papers. In the system I am working on, terms are simply the terms of pure untyped lambda calculus. All the action is in the types we can assign to such terms, and the kinding of those types. For practical purposes, one will eventually need to design an annotated version of such a language, since inferring a type for a pure term of lambda calculus, even just in System F (a subsystem of my system), is undecidable. But for metatheoretic analysis, this Curry-style development, where terms are completely unannotated, is fine. In fact, it is more than fine, it is enlightening. ECC is based on a Church-style approach to the syntax of terms. Types are really legitimate parts of terms, that could be computed at run-time (though nothing interesting at run-time could be done with them). This, by the way, is another point of ICC that I do not agree with: types can be parts of terms “really”, even though they do not have to be.
I am locating the central issue with the Coquand/Mohring counterexample to large eliminations with nonstrictly positive inductive types in the fact that the element of the inductive type in question can store a type (actually, something of type ). This type is really like a piece of data inside the element of the inductive type. It can be retrieved and processed, and this leads to the paradox. Rather than blocking large eliminations with inductive types, I propose to shift the ground completely by using a Curry-style theory. So types cannot be stored inside elements of datatypes, and thus cannot be retrieved and manipulated. I believe this would block that counterexample, while still allowing both nonstrictly positive inductive types and large eliminations over impredicative inductive types. I have a proof that this works for the first of these features, and I believe I shall have a proof for the second (large eliminations) in the next few months.
Hoping to have stirred the pot, I wish anyone reading to this point all the best in their investigations of type theory, or whatever other subjects deprive them of sleep and fire their minds.