| 1 |
(*I get an Anomaly in the following code. |
| 2 |
|
| 3 |
```*) |
| 4 |
Require Import TestSuite.vector. |
| 5 |
|
| 6 |
Module M. |
| 7 |
Lemma Vector_map_map : |
| 8 |
forall A B C (f : A -> B) (g : B -> C) n (v : Vector.t A n), |
| 9 |
Vector.map g (Vector.map f v) = Vector.map (fun a => g (f a)) v. |
| 10 |
Proof. |
| 11 |
induction v; simpl; auto using f_equal. |
| 12 |
Qed. |
| 13 |
|
| 14 |
Lemma Vector_map_map_transparent : |
| 15 |
forall A B C (f : A -> B) (g : B -> C) n (v : Vector.t A n), |
| 16 |
Vector.map g (Vector.map f v) = Vector.map (fun a => g (f a)) v. |
| 17 |
Proof. |
| 18 |
induction v; simpl; auto using f_equal. |
| 19 |
Defined. |
| 20 |
(* Anomaly: constant not found in kind_of_head: Coq.Vectors.Vector.t_ind. Please report. *) |
| 21 |
|
| 22 |
(* strangely, explicitly passing the principle to induction works *) |
| 23 |
Lemma Vector_map_map_transparent' : |
| 24 |
forall A B C (f : A -> B) (g : B -> C) n (v : Vector.t A n), |
| 25 |
Vector.map g (Vector.map f v) = Vector.map (fun a => g (f a)) v. |
| 26 |
Proof. |
| 27 |
induction v using Vector.t_ind; simpl; auto using f_equal. |
| 28 |
Defined. |
| 29 |
End M. |
| 30 |
(*``` |
| 31 |
|
| 32 |
Changing any of the following things eliminates the Anomaly |
| 33 |
* moving the lemma out of the module M to the top level |
| 34 |
* proving the lemma as a Fixpoint instead of using induction |
| 35 |
* proving the analogous lemma on lists instead of vectors*) |