This is a follow-up question to Getting path induction to work in Agda
I wonder when that construct may be more expressive. It seems to me we can always express the
To provide a short answer: you're right, Agda's pattern matching implies the existence of a path-induction primitive. In fact, it has been shown that in a type theory with universes, dependent pattern matching is equivalent to the existence of induction primitives for inductive types and the so-called K axiom:
http://link.springer.com/chapter/10.1007/11780274_27
More recently, it has been shown that (the latest implementation of) Agda's --without-K option restricts pattern matching such that it is only equivalent with the existence of induction primitives for inductive types:
http://dl.acm.org/citation.cfm?id=2628136.2628139
Full disclosure: I'm a co-author of the latter work.
pathInd
is just a dependent eliminator. Here is an isomorphic definition:
J : ∀ {α β} {A : Set α} {x y : A}
-> (C : {x y : A} {p : x ≡ y} -> Set β)
-> ({x : A} -> C {x} {x})
-> (p : x ≡ y) -> C {p = p}
J _ b refl = b
Having this, you can define various functions on _≡_
without pattern-matching, for example:
sym : ∀ {α} {A : Set α} {x y : A}
-> x ≡ y
-> y ≡ x
sym = J (_ ≡ _) refl
trans : ∀ {α} {A : Set α} {x y z : A}
-> x ≡ y
-> y ≡ z -> x ≡ z
trans = J (_ ≡ _ -> _ ≡ _) id
cong : ∀ {α β} {A : Set α} {B : Set β} {x y : A}
-> (f : A -> B)
-> x ≡ y
-> f x ≡ f y
cong f = J (f _ ≡ f _) refl
subst : ∀ {α β} {A : Set α} {x y : A}
-> (C : A -> Set β)
-> x ≡ y
-> C x -> C y
subst C = J (C _ -> C _) id
But you can't prove uniqueness of identity proofs from J
as described at [1]:
uip : ∀ {α} {A : Set α} {x y : A} -> (p q : x ≡ y) -> p ≡ q
uip refl refl = refl
So you can express more with Agda's pattern-matching, than with just a dependent eliminator for _≡_
. But you can use the --without-K
option:
{-# OPTIONS --without-K #-}
open import Relation.Binary.PropositionalEquality
uip : ∀ {α} {A : Set α} {x y : A} -> (p q : x ≡ y) -> p ≡ q
uip refl refl = refl
uip
doesn't typecheck now, causing this error:
Cannot eliminate reflexive equation x = x of type A because K has
been disabled.
when checking that the pattern refl has type x ≡ x
[1] http://homotopytypetheory.org/2011/04/10/just-kidding-understanding-identity-elimination-in-homotopy-type-theory/