| 1 |
Record TYPE := Pack_TYPE { sort_TYPE :> Type }. |
| 2 |
Record eqType := Pack_eq { sort_eq :> Type; _ : sort_eq -> sort_eq -> bool }. |
| 3 |
|
| 4 |
Definition eq_op (T : eqType) : T -> T -> bool := |
| 5 |
match T with Pack_eq _ op => op end. |
| 6 |
|
| 7 |
Definition bool_eqb b1 b2 := |
| 8 |
match b1, b2 with |
| 9 |
| false, false => true |
| 10 |
| true, true => true |
| 11 |
| _, _ => false |
| 12 |
end. |
| 13 |
|
| 14 |
Canonical bool_TYPE := Pack_TYPE bool. |
| 15 |
Canonical bool_eqType := Pack_eq bool bool_eqb. |
| 16 |
|
| 17 |
Canonical nat_TYPE := Pack_TYPE nat. |
| 18 |
Canonical nat_eqType := Pack_eq nat Nat.eqb. |
| 19 |
|
| 20 |
Definition prod_eqb (T U : eqType) (x y : T * U) := |
| 21 |
match x, y with |
| 22 |
| (x1, x2), (y1, y2) => |
| 23 |
andb (eq_op _ x1 y1) (eq_op _ x2 y2) |
| 24 |
end. |
| 25 |
|
| 26 |
Canonical prod_TYPE (T U : TYPE) := Pack_TYPE (T * U). |
| 27 |
Canonical prod_eqType (T U : eqType) := Pack_eq (T * U) (prod_eqb T U). |
| 28 |
|
| 29 |
Definition sum_eqb (T U : eqType) (x y : T + U) := |
| 30 |
match x, y with |
| 31 |
| inl x, inl y => eq_op _ x y |
| 32 |
| inr x, inr y => eq_op _ x y |
| 33 |
| _, _ => false |
| 34 |
end. |
| 35 |
|
| 36 |
Canonical sum_TYPE (T U : TYPE) := Pack_TYPE (T + U). |
| 37 |
Canonical sum_eqType (T U : eqType) := Pack_eq (T + U) (sum_eqb T U). |
| 38 |
|
| 39 |
Print Canonical Projections bool. |
| 40 |
Print Canonical Projections nat. |
| 41 |
Print Canonical Projections prod. |
| 42 |
Print Canonical Projections sum. |
| 43 |
Print Canonical Projections sort_TYPE. |
| 44 |
Print Canonical Projections sort_eq. |
| 45 |
Print Canonical Projections sort_TYPE bool. |
| 46 |
Print Canonical Projections bool_eqType. |