2014-01-05 16:52:46 +00:00
|
|
|
-- "Type casting" library.
|
2013-12-24 06:04:19 +00:00
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
-- The cast operator allows us to cast an element of type A
|
|
|
|
-- into B if we provide a proof that types A and B are equal.
|
2014-01-05 20:05:08 +00:00
|
|
|
variable cast {A B : (Type U)} : A == B → A → B.
|
2014-01-05 16:52:46 +00:00
|
|
|
|
|
|
|
-- The CastEq axiom states that for any cast of x is equal to x.
|
2014-01-06 03:10:21 +00:00
|
|
|
axiom cast::eq {A B : (Type U)} (H : A == B) (x : A) : x == cast H x.
|
2013-12-24 06:04:19 +00:00
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
-- The CastApp axiom "propagates" the cast over application
|
2014-01-06 03:10:21 +00:00
|
|
|
axiom cast::app {A A' : (Type U)} {B : A → (Type U)} {B' : A' → (Type U)}
|
2014-01-08 08:38:39 +00:00
|
|
|
(H1 : (∀ x : A, B x) == (∀ x : A', B' x)) (H2 : A == A')
|
|
|
|
(f : ∀ x : A, B x) (x : A) :
|
2013-12-24 06:04:19 +00:00
|
|
|
cast H1 f (cast H2 x) == f x.
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
-- If two (dependent) function spaces are equal, then their domains are equal.
|
2014-01-06 03:10:21 +00:00
|
|
|
axiom dominj {A A' : (Type U)} {B : A → (Type U)} {B' : A' → (Type U)}
|
2014-01-08 08:38:39 +00:00
|
|
|
(H : (∀ x : A, B x) == (∀ x : A', B' x)) :
|
2013-12-24 06:04:19 +00:00
|
|
|
A == A'.
|
|
|
|
|
2014-01-05 16:52:46 +00:00
|
|
|
-- If two (dependent) function spaces are equal, then their ranges are equal.
|
2014-01-06 03:10:21 +00:00
|
|
|
axiom raninj {A A' : (Type U)} {B : A → (Type U)} {B' : A' → (Type U)}
|
2014-01-08 08:38:39 +00:00
|
|
|
(H : (∀ x : A, B x) == (∀ x : A', B' x)) (a : A) :
|
2014-01-06 03:10:21 +00:00
|
|
|
B a == B' (cast (dominj H) a).
|