| 1 |
Inductive foo : nat -> Type := |
| 2 |
| fz : foo 0 |
| 3 |
| fs : forall {n}, foo (S n). |
| 4 |
|
| 5 |
Definition test (n : nat) : foo n -> nat. |
| 6 |
refine ( |
| 7 |
match n with |
| 8 |
| 0 => |
| 9 |
fun f => |
| 10 |
match f in foo n return match n with 0 => nat | S _ => unit end with |
| 11 |
| fz => 0 |
| 12 |
| fs => tt |
| 13 |
end |
| 14 |
| S n => |
| 15 |
fun f => |
| 16 |
match f in foo n return match n with 0 => unit | S _ => nat end with |
| 17 |
| fz => tt |
| 18 |
| fs => 42 |
| 19 |
end |
| 20 |
end). |
| 21 |
Qed. |
| 22 |
|
| 23 |
Definition test2 n : foo n -> nat. |
| 24 |
refine ( |
| 25 |
match n with |
| 26 |
| 0 => |
| 27 |
fun (f: foo 0) => |
| 28 |
match f in foo n return match n with 0 => nat | S _ => unit end with |
| 29 |
| fz => 0 |
| 30 |
| fs => tt |
| 31 |
end |
| 32 |
| S n => |
| 33 |
fun f => |
| 34 |
match f in foo n return match n with 0 => unit | S _ => nat end with |
| 35 |
| fz => tt |
| 36 |
| fs => 42 |
| 37 |
end |
| 38 |
end). |
| 39 |
Qed. |
| 40 |
|
| 41 |
Definition test3 (n : nat) : foo n -> nat := |
| 42 |
match n with |
| 43 |
| 0 => |
| 44 |
fun f => |
| 45 |
match f in foo n return match n with 0 => nat | S _ => unit end with |
| 46 |
| fz => 0 |
| 47 |
| fs => tt |
| 48 |
end |
| 49 |
| S n => |
| 50 |
fun f => |
| 51 |
match f in foo n return match n with 0 => unit | S _ => nat end with |
| 52 |
| fz => tt |
| 53 |
| fs => 42 |
| 54 |
end |
| 55 |
end. |
| 56 |
|
| 57 |
Definition test4 (n : nat) : bool -> foo n -> nat := |
| 58 |
match n with |
| 59 |
| 0 => |
| 60 |
fun b f => |
| 61 |
match f in foo n return match n with 0 => nat | S _ => unit end with |
| 62 |
| fz => 0 |
| 63 |
| fs => tt |
| 64 |
end |
| 65 |
| S _ => |
| 66 |
fun b f => |
| 67 |
match f in foo n return match n with 0 => unit | S _ => nat end with |
| 68 |
| fz => tt |
| 69 |
| fs => 42 |
| 70 |
end |
| 71 |
end. |