| 1 |
Inductive Empty : Prop := . |
| 2 |
|
| 3 |
Inductive paths {A : Type} (a : A) : A -> Prop := |
| 4 |
idpath : paths a a. |
| 5 |
|
| 6 |
Notation "x = y :> A" := (@paths A x y) : type_scope. |
| 7 |
Notation "x = y" := (x = y :>_) : type_scope. |
| 8 |
|
| 9 |
Arguments idpath {A a} , [A] a. |
| 10 |
|
| 11 |
Definition idmap {A : Type} : A -> A := fun x => x. |
| 12 |
|
| 13 |
Definition path_sum {A B : Type} (z z' : A + B) |
| 14 |
(pq : match z, z' with |
| 15 |
| inl z0, inl z'0 => z0 = z'0 |
| 16 |
| inr z0, inr z'0 => z0 = z'0 |
| 17 |
| _, _ => Empty |
| 18 |
end) |
| 19 |
: z = z'. |
| 20 |
destruct z, z', pq; exact idpath. |
| 21 |
Defined. |
| 22 |
|
| 23 |
Definition ap {A B:Type} (f:A -> B) {x y:A} (p:x = y) : f x = f y |
| 24 |
:= match p with idpath => idpath end. |
| 25 |
|
| 26 |
Theorem ex2_8 {A B A' B' : Type} (g : A -> A') (h : B -> B') (x y : A + B) |
| 27 |
(* Fortunately, this unifies properly *) |
| 28 |
(pq : match (x, y) with (inl x', inl y') => x' = y' | (inr x', inr y') => x' = y' | _ => Empty end) : |
| 29 |
let f z := match z with inl z' => inl (g z') | inr z' => inr (h z') end in |
| 30 |
ap f (path_sum x y pq) = path_sum (f x) (f y) |
| 31 |
(* Coq appears to require *ALL* of the annotations *) |
| 32 |
((match x as x return match (x, y) with |
| 33 |
(inl x', inl y') => x' = y' |
| 34 |
| (inr x', inr y') => x' = y' |
| 35 |
| _ => Empty |
| 36 |
end -> match (f x, f y) with |
| 37 |
| (inl x', inl y') => x' = y' |
| 38 |
| (inr x', inr y') => x' = y' |
| 39 |
| _ => Empty end with |
| 40 |
| inl x' => match y as y return match y with |
| 41 |
inl y' => x' = y' |
| 42 |
| _ => Empty |
| 43 |
end -> match f y with |
| 44 |
| inl y' => g x' = y' |
| 45 |
| _ => Empty end with |
| 46 |
| inl y' => ap g |
| 47 |
| inr y' => idmap |
| 48 |
end |
| 49 |
| inr x' => match y as y return match y with |
| 50 |
inr y' => x' = y' |
| 51 |
| _ => Empty |
| 52 |
end -> match f y with |
| 53 |
| inr y' => h x' = y' |
| 54 |
| _ => Empty end with |
| 55 |
| inl y' => idmap |
| 56 |
| inr y' => ap h |
| 57 |
end |
| 58 |
end) pq). |
| 59 |
destruct x; destruct y; destruct pq; reflexivity. |
| 60 |
Qed. |
| 61 |
(* Toplevel input, characters 1367-1374: |
| 62 |
Error: |
| 63 |
In environment |
| 64 |
A : Type |
| 65 |
B : Type |
| 66 |
A' : Type |
| 67 |
B' : Type |
| 68 |
g : A -> A' |
| 69 |
h : B -> B' |
| 70 |
x : A + B |
| 71 |
y : A + B |
| 72 |
pq : |
| 73 |
match x with |
| 74 |
| inl x' => match y with |
| 75 |
| inl y' => x' = y' |
| 76 |
| inr _ => Empty |
| 77 |
end |
| 78 |
| inr x' => match y with |
| 79 |
| inl _ => Empty |
| 80 |
| inr y' => x' = y' |
| 81 |
end |
| 82 |
end |
| 83 |
f := |
| 84 |
fun z : A + B => |
| 85 |
match z with |
| 86 |
| inl z' => inl (g z') |
| 87 |
| inr z' => inr (h z') |
| 88 |
end : A + B -> A' + B' |
| 89 |
x' : B |
| 90 |
y0 : A + B |
| 91 |
y' : B |
| 92 |
The term "x' = y'" has type "Type" while it is expected to have type |
| 93 |
"Prop" (Universe inconsistency). *) |