(f a) is ill-typed where f:(x:A)B and a:A'. If there is a
path coercion between A' and A, (f a) is transformed into
(f a') where a' is the result of the application of this
path coercion to a.
Coq < Variables C:nat->Set; D:nat->bool->Set; E:bool->Set.
C is assumed
D is assumed
E is assumed
Coq < Variable f : (n:nat)(C n) -> (D (S n) true).
f is assumed
Coq < Coercion f : C >-> D.
f is now a coercion
Coq < Variable g : (n:nat)(b:bool)(D n b) -> (E b).
g is assumed
Coq < Coercion g : D >-> E.
g is now a coercion
Coq < Variable c : (C O).
c is assumed
Coq < Variable T : (E true) -> nat.
T is assumed
Coq < Check (T c).
(T c)
: nat
We give now an example using identity coercions.
Coq < Definition D' := [b:bool](D (S O) b).
D' is defined
Coq < Identity Coercion IdD'D : D' >-> D.
IdD'D is now a coercion
Coq < Print IdD'D.
IdD'D = [b:bool][x:(D' b)]x
: (b:bool)(D' b)->(D (S O) b)
Coq < Variable d' : (D' true).
d' is assumed
Coq < Check (T d').
(T d')
: nat
In the case of functional arguments, we use the monotonic rule of
subtyping. Approximatively, to coerce t:(x:A)B towards (x:A')B',
one have to coerce A' towards A and B towards B'. An example
is given below:
Coq < Variables A,B:Set; h:A->B.
A is assumed
B is assumed
h is assumed
Coq < Coercion h : A >-> B.
h is now a coercion
Coq < Variable U : (A -> (E true)) -> nat.
U is assumed
Coq < Variable t : B -> (C O).
t is assumed
Coq < Check (U t).
(U [x:A](t x))
: nat
Remark the changes in the result following the modification of the
previous example.
Coq < Variable U' : ((C O) -> B) -> nat.
U' is assumed
Coq < Variable t' : (E true) -> A.
t' is assumed
Coq < Check (U' t').
(U' [x:(C O)](t' x))
: nat