I'll try to explain this without mentioning "K" or "UIP".
Here's a proof in Coq -- unfortunately, it uses JMeq_ind
(it is supposed to be the eliminator/induction principle of JMeq
) which is based on JMeq_eq
:
Require Import Coq.Logic.JMeq.
Definition JMeq_eq2 : forall (A : Type) (x y : A),
JMeq x y -> x = y.
Proof.
intros A x.
apply (JMeq_ind (x := x) (fun a => x = a)).
reflexivity.
Qed.
This is consistent with impredicative Set (citation needed -- this is just a guess). Under the default setting of Agda, you can prove it (JMeq
in Agda is ≅
) as wel:
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.HeterogeneousEquality
JMeq-eq : (A : Set) (x y : A) -> (x ≅ y) -> x ≡ y
JMeq-eq A x y refl = refl
However, this works only because Agda by default enables --with-K
mode (if you don't understand what is K
, don't worry), which have less restrictions to the pattern matching as well as definitions of inductive types.
Agda will reject the simplest definition (say, no universe polymorphism) of JMeq
if we enable --without-K
explicitly (this simply disable --with-K
. Coq is under this mode by default):
{-# OPTIONS --without-K #-}
infix 4 _≅_
data _≅_ {A : Set} (x : A) : {B : Set} → B → Set where
refl : x ≅ x
The way Agda rejects it is by restricting the level of indices, they need to have lower level than the inductive type itself:
Set₁ is not less or equal than Set
when checking the definition of _≅_
If you want a universe in the indices under --without-K
, you need to explicitly make the level of B
less than A
(so you have to do something like data _≅_ {A : Set (suc l)} (x : A) : {B : Set l} → B → Set (suc l)
), which makes x
(which is an instance of A
) an invalid instance of type B
. Agda has to do this because it will automatically generate a "≅_ind
" if you can define ≅
, and we call it dependent pattern matching.
In Coq, universe polymorphism is automatically resolved by the compiler, so this trick won't work in Coq. I think Coq simply don't have an eliminator for JMeq
built-in, so the situation is similar to Agda with the restrictions.
dynE
lemma at the end of the linked file. $\endgroup$ – Anton Trunov Mar 15 '19 at 16:48inj_pair2
in Coq). FromJMeq_eq x y
followsexistT id A x = existT id A y
and usinginj_pair2
we getx = y
. $\endgroup$ – Anton Trunov Mar 15 '19 at 20:55