[Agda] heterogeneous equality, library functions
Florent Balestrieri
fyb at cs.nott.ac.uk
Tue Feb 9 12:05:43 CET 2010
Hello,
I feel that some of the library functions dealing with heterogeneous
equality could be made more general.
Especially the `subst2' function which actually (lib 2.2.7) takes a
predicate `P : A -> B -> Set' when it could instead use a dependant type
`P : (x : A) -> B x -> Set'.
The `cong2' function already used dependent types, but then it asked for
an hetero equality on `x' and `y' which both have the same type `A' so I
made it a propositional equality instead. It makes life easier because I
was always converting from prop to hetero for this argument.
I also generalised the datatype Inspect, although I'm not sure about its
usefulness ; but I definitely needed the generalised subst.
Attached is a module with some replacement definitions for the above
functions.
-- Florent
-------------- next part --------------
{-# OPTIONS --universe-polymorphism #-}
module Extra.HeteroEq where
open import Level
using (Level ; suc ; _â_)
open import Relation.Binary.PropositionalEquality
using ( _â¡_ ; refl )
open import Relation.Binary.HeterogeneousEquality
using ( _â
_ ; refl )
------------------------------------------------------------
substâ
: {a b c : Level}
{A : Set a}
{B : A â Set b}
(C : (x : A) â B x â Set c)
{xâ xâ : A}
{yâ : B xâ}
{yâ : B xâ}
â xâ â¡ xâ
â yâ â
yâ
â C xâ yâ
â C xâ yâ
substâ _ refl refl c
= c
substâ
: {a b c d : Level}
{A : Set a}
{B : A â Set b}
{C : (x : A) â B x â Set c}
(D : (x : A) â (y : B x) â C x y â Set d)
{xâ xâ : A}
{yâ : B xâ}
{yâ : B xâ}
{zâ : C xâ yâ}
{zâ : C xâ yâ}
â xâ â¡ xâ
â yâ â
yâ
â zâ â
zâ
â D xâ yâ zâ
â D xâ yâ zâ
substâ _ refl refl refl d
= d
------------------------------------------------------------
substâ-removable
: {a b c : Level}
{A : Set a}
{B : A â Set b}
(C : (x : A) â B x â Set c)
{xâ xâ : A}
{yâ : B xâ}
{yâ : B xâ}
(x : xâ â¡ xâ)
(y : yâ â
yâ)
(t : C xâ yâ)
â substâ C x y t â
t
substâ-removable _ refl refl t
= refl
substâ-removable
: {a b c d : Level}
{A : Set a}
{B : A â Set b}
{C : (x : A) â B x â Set c}
(D : (x : A) â (y : B x) â C x y â Set d)
{xâ xâ : A}
{yâ : B xâ}
{yâ : B xâ}
{zâ : C xâ yâ}
{zâ : C xâ yâ}
(x : xâ â¡ xâ)
(y : yâ â
yâ)
(z : zâ â
zâ)
(t : D xâ yâ zâ)
â substâ D x y z t â
t
substâ-removable _ refl refl refl t
= refl
------------------------------------------------------------
congâ
: {a b c : Level}
{A : Set a}
{B : A â Set b}
{C : (x : A) â B x â Set c}
(f : (x : A) â (y : B x) â C x y)
{xâ xâ : A}
{yâ : B xâ}
{yâ : B xâ}
â xâ â¡ xâ
â yâ â
yâ
â f xâ yâ â
f xâ yâ
congâ f refl refl
= refl
congâ
: {a b c d : Level}
{A : Set a}
{B : A â Set b}
{C : (x : A) â B x â Set c}
{D : (x : A) â (y : B x) â C x y â Set d}
(f : (x : A) â (y : B x) â (z : C x y) â D x y z)
{xâ xâ : A}
{yâ : B xâ}
{yâ : B xâ}
{zâ : C xâ yâ}
{zâ : C xâ yâ}
â xâ â¡ xâ
â yâ â
yâ
â zâ â
zâ
â f xâ yâ zâ â
f xâ yâ zâ
congâ f refl refl refl
= refl
------------------------------------------------------------
data Inspect {a b : Level} {A : Set a} (x : A)
: Set (a â suc b)
where
_with-â
_ : {B : Set b} (y : B) (eq : y â
x) â Inspect x
inspect : â {a} {A : Set a} (x : A) â Inspect x
inspect x = x with-â
refl
More information about the Agda
mailing list