I was trying to prove K (with without-K) using J to see what goes wrong when we try to do that.
That's all well and good, but in the process of playing around I noticed that agda refuses to match with refl any term (that I tried) of type Id A x x (saying something along the lines of "can't unify x1 ≟ x1").
For example, agda refuses to case split on p in the following example:
data 1 : Type where
* : 1
test : {l : Level} {A : Type l} -> (x : A) -> (p : x ≡ x) -> 1
test {l} {A} x p = ?
but the following snippet is fine:
data 1 : Type where
* : 1
test : {l : Level} {A : Type l} -> (x : A) -> (p : x ≡ x) -> 1
test {l} {A} x p = J {A = A} {x = x} (λ y path -> 1) {y = x} p *
Isn't using J here like this essentially the same as case-splitting on p and assuming it to be refl? If yes, then why does agda refuse to split on p in the earlier example?
For reference the type of the J rule being used is this:
J : {A : Set a} {x : A} (B : (y : A) → x ≡ y → Set b)
{y : A} (p : x ≡ y) → B x refl → B y p
2 Answers 2
Your use of J is roughly equivalent to defining a helper function that pattern matches on a fully general path p : x ≡ y, then calling it with y = x:
test : {l : Level} {A : Type l} -> (x : A) -> (p : x ≡ x) -> 1
test {l} {A} x p = test' {y = x} p where
test' : {y : A} -> (p : x ≡ y) -> 1
test' refl = *
2 Comments
x and y, then pattern matching.y in x = y must be a free variable as it is quantified in B : (y : A) → x ≡ y → Set b for this reasin it can not be specialize to x when doing an induction.
So if you want to prove sth for equality, you must first prove sth for x = y to deduce it for x = x, which is not possible for UIP / axiom K.
2 Comments
B : (y : A) → x ≡ y → Set b y is quantified so it can not be a specific valueExplore related questions
See similar questions with these tags.
test : {l : Level} {A : Set l} -> (x : A) -> (p : x ≡ x) -> p ≡ reflusingJ. It's obviously easy if you allow pattern matching with K. Note that this challenge requires you to use the fact that p must be reflexivity, something you learn from the pattern match on p.Jcould be replaced with an equivalent use ofsubst, and the version ofsubstin whichxandyare judgementally equal is obviously derivable without K (you just ignore the pathx ≡ xand return the identity functionP x → P x).