Path induction implied

后端 未结 2 1221
情深已故
情深已故 2021-01-06 19:40

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

2条回答
  •  失恋的感觉
    2021-01-06 20:02

    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/

提交回复
热议问题