β¦probably. To be clear, ECIC1 refers to Monnier and Bosβ Erasable CIC2, with erasable in the sense of erasable pure type systems (EPTS)3. Iβll argue that even with erased impredicative fields, Coquandβs paradox of trees4 is still typeable.
ECIC
I wonβt go too much into detail on the definition of ECIC, but Iβll touch on some key rules and examples. In short, ECIC is CIC, but:
- Function arguments can be erased or normal;
- Erased arguments may only appear in type annotations that are erased prior to evaluation5;
- Inductives may only live in Prop;
- Large arguments of constructors must be erased; and
- There are no restrictions on what inductives may be eliminated into6.
They claim that erasure of large arguments is what permits unrestricted inductive elimination, but I believe that this is still inconsistent.
To establish some syntax, hereβs the typing rule for function types and functions with erased arguments, where is the erasure of a term, which erases type annotations as well as erased arguments entirely.
The PTS rules are , , and most importantly, . The last rule says that if you want to use something large for a proposition, it must be erasable, and therefore only used in type annotations. A key theorem states that if a term is typeable is CIC, then itβs typeable in ECIC with additional erasure annotations, meaning that CIC inherently never uses impredicativity in computationally relevant ways.
The typing rules for inductives and especially their case expressions, as usual, are rather involved, and I wonβt repeat them here. Instead, to establish its syntax, hereβs an example defining propositional equality as an inductive, and a proof that itβs symmetric. From here onwards Iβll use square brackets to indicate erased arguments, omitting annotations entirely, as well as as a shorthand for nondependent function types.
This equality is over large terms to be able to talk about both equal propositions and equal proofs7, so basically all arguments except for equality itself must be erased. However, it still doesnβt qualify as a large inductive, since none of the constructor arguments are large, i.g. have types in sort . Contrariwise, the following inductive is large, requiring its first constructor argument to be erased to justify unrestricted elimination.
Digression: Rocqβs and
ECICβs is neither like Rocqβs nor like its impredicative , which Iβll call and to avoid confusion. Large inductives in either and are not allowed to be strongly eliminated, because this would be inconsistent. Furthermore, as members of types of sort are intended to be erased during extraction, inductives in with multiple constructors canβt be strongly eliminated either, so that case expressions only have a single branch to which they erase. This makes eCICβs , confusingly, exactly Rocqβs impredicative .
The paradox of trees
Coquandβs paradox of trees develops an inconsistency out of the inductive above by showing that simultaneously all are well founded and there exists a that is not well founded, in particular below.
is injective
Before we continue, we need an injectivity lemma saying that if two s are equal, then their components are equal too. I omit the expression in the body because itβs already in the type. Importantly, when matching on the s, the large, erased first argument of the constructor is only used in erased positions.
The equalities make its statement a bit convoluted,
but the proof is ultimately a pair of reflexivities.
It would perhaps be clearer to see the equivalent Rocq proof,
which uses rew
notations to make it cleaner.
Here, I need to turn off universe checking when defining the inductive
to prevent Rocq from disallowing its strong elimination.
Notably, this is the only place where turning off universe checking is required,
and the type of is the only place where strong elimination occurs.
Import EqNotations.
Unset Universe Checking.
Inductive U : Prop := u (X : Prop) (f : X -> U) : U.
Set Universe Checking.
Definition loop : U := u U (fun x => x).
Definition injU [u1 u2 : U] (p : u1 = u2) :
match u1, u2 with
| u X1 f1, u X2 f2 =>
exists (q : X1 = X2),
rew [fun Z => Z -> U] q in f1 = f2
end :=
rew dependent p in
match u1 with
| u _ _ => ex_intro _ eq_refl eq_refl
end.
s are well founded
The wellfoundedness predicate is another inductive stating that a is well founded if all of its children are. Wellfoundedness for all is easily proven by induction.
Again, hereβs the equivalent definitions in Rocq. Thereβs no need to turn off universe checking this time since we wonβt be strongly eliminating .
Inductive WF : U -> Prop :=
| wf : forall X f, (forall x, WF (f x)) -> WF (u X f).
Fixpoint wfU (u : U) : WF u :=
match u with
| u X f => wf X f (fun x => wfU (f x))
end.
is not well founded
Showing nonwellfoundedness of is more complicated, not because itβs an inherently difficult proof, but because it requires manually unifying indices. In fact, the whole proof in Agda is quite simple.
{-# NO_UNIVERSE_CHECK #-}
data U : Set where
u : (X : Set) β (X β U) β U
data WF : U β Setβ where
wf : β (X : Set) (f : X β U) β (β x β WF (f x)) β WF (u X f)
loop = u U (Ξ» x β x)
nwf : WF loop β β₯
nwf (wf X f h) = nwf (h loop)
Destructing as , we know that is and is . In Rocq, we have the help of tactics and dependent induction, as well as proven earlier to explicitly unify indices.
Require Import Coq.Program.Equality.
Lemma nwf (u : U) (p : u = loop) (wfl : WF u) : False.
Proof.
dependent induction wfl.
apply injU in p as [q r].
simpl in q. subst.
simpl in r. subst.
eapply H0. reflexivity.
Qed.
But writing the same proof in plain ECIC is a challenge,
especially as the proof term generated for nwf
is disgusting.
Iβve simplified it to the following to the best of my ability,
still using copious amounts of rew
.
Fixpoint nwf (wfl : WF loop) : False :=
match wfl in WF u' return loop = u' -> False with
| wf _ f h => fun p => let (q , r) := injU p in
(rew dependent [fun _ q => forall f,
rew [fun Z => Z -> U] q in (fun x => x) = f
-> (forall x, WF (f x))
-> False] q
in fun _ r =>
rew [fun f => (forall x, WF (f x)) -> False] r
in fun h => nwf (h loop)) f r h
end eq_refl.
I wonβt bother trying to typeset that in ECIC, but I hope itβs convincing enough as an argument that the corresponding definition would still type check and that erasure isnβt violated, i.e. that the argument from the isnβt used in the body of the proof. This proof doesnβt even use strong elimination, either: the return type of every case expression lives in .
Why isnβt ECIC consistent?
The proof sketch above tells us how ECIC isnβt consistent, but we still need to understand why it isnβt consistent. ECICβs original argument was that
forcing impredicative fields to be erasable also avoids this source of inconsistency usually avoided with the constraint.
Said source refers to the ability for large impredicative inductives with strong elimination to hide a larger type within a smaller construction thatβs then used later. The idea is that if the impredicative field is erased, then surely it canβt be meaningfully used later as usual to construct an inconsistency. Here, Iβve shown that it can be meaningfully used even if it canβt be used relevantly, because all we need is to be able to refer to them in propositions and proofs. It doesnβt really make sense anyway that the computational relevance of a term should have any influence on propositions, which arguably exist independently of whether they can be computed.
Then why is strong elimination inconsistent with impredicativity, if computational relevance isnβt the reason? I believe that the real connection is between impredicativity and proof irrelevance, from which computational irrelevance arises. After all, is often modelled proof-irrelevantly as a two-element set , collapsing all of its types to truthhood or falsehood and disregarding those typesβ inhabitants. Other times, is defined as the universe of mere propositions, or the universe of types such that their inhabitants (if any) are all propositionally equal.
Under this view, impredicativity is permitted, although not necessary, because referring to larger information ought to be safe so long as thereβs no way to use that information to violate proof irrelevance. Strong elimination commits this violation because, as seen in , it allows us to talk about the identity (or non-identity) of larger terms, even if the way we talk about it is proof-irrelevantly. Concretely, the contrapositive of lets us distinguish two s as soon as we have two provably unequal types, such as and , from which we can provably distinguish and .
Interestingly, even without strong elimination of large inductives, proof irrelevance can still be violated by strong elimination of a small inductive with two constructors, since that would enable proving the two constructors unequal. The only way an inconsistency arises is if proof irrelevance is explicitly internalized. This is why the axiom of excluded middle is inconsistent in the presence of strong elimination in this setting: Berardiβs paradox8 says that EM implies proof irrelevance. I think thereβs something profound in this paradox that I havenβt yet grasped, because connects two different views of a proposition: as something that is definitively either true or false, or as something that carries no other information than whether it is true or false.
-
Not to be confused with their eCIC, the erasable CIC.Β ↩
-
Stefan Monnier; Nathaniel Bos. Is Impredicativity Implicitly Implicit? TYPES 2019. doi:10.4230/LIPIcs.TYPES.2019.9.Β ↩
-
Nathan Mishra-Linger; Tim Sheard. Erasure and polymorphism in pure type systems. FOSSACS 2008. doi:10.5555/1792803.1792828.Β ↩
-
Thierry Coquand. The paradox of trees in type theory. BIT 32 (1992). doi:10.1007/BF01995104.Β ↩
-
Also called run-time erasure, run-time irrelevance, computational irrelevance, or external erasure.Β ↩
-
Also called the no-SELIT (strong elimination of large inductive types) rule.Β ↩
-
ECIC doesnβt formally have cumulativity, but we can use our imaginations.Β ↩
-
Barbanera, Franco; Berardi, Stefano. JFP 1996. Proof-irrelevance out of excluded middle and choice in the calculus of constructions. doi:10.1017/S0956796800001829.Β ↩