Skip to content

Commit 3122783

Browse files
committed
added nil_spec, removed pattern
1 parent aa6b01b commit 3122783

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

theories/Vectors/Fin.v

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,8 @@ Qed.
161161

162162
Lemma L_inj {m} n (p q : t m) : L n p = L n q -> p = q.
163163
Proof.
164-
induction p as [m|m p IH]; pattern q.
165-
- now apply caseS'.
166-
- apply caseS'; [discriminate|].
167-
intros ??. f_equal. now apply IH, FS_inj.
164+
induction p as [m|m p IH]; apply (caseS' q); [easy..|].
165+
intros ??. f_equal. now apply IH, FS_inj.
168166
Qed.
169167

170168
(** The p{^ th} element of [fin m] viewed as the p{^ th} element of

theories/Vectors/VectorSpec.v

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ Definition cons_inj {A} {a1 a2} {n} {v1 v2 : t A n}
2424
with | eq_refl => conj eq_refl eq_refl
2525
end.
2626

27+
Lemma nil_spec {A} (v : t A 0) : v = [].
28+
Proof.
29+
apply (fun P E => case0 P E v). reflexivity.
30+
Defined.
31+
2732
Lemma eta {A} {n} (v : t A (S n)) : v = hd v :: tl v.
2833
Proof.
29-
intros; apply (fun P IS => caseS P IS (n := n) v); intros; reflexivity.
34+
apply (fun P IS => caseS P IS (n := n) v); intros; reflexivity.
3035
Defined.
3136

3237
(** Lemmas are done for functions that use [Fin.t] but thanks to [Peano_dec.le_unique], all
@@ -103,17 +108,18 @@ Qed.
103108
Lemma nth_replace_eq A: forall n p (v : t A n) a,
104109
nth (replace v p a) p = a.
105110
Proof.
106-
intros n p v a. induction v; pattern p.
107-
- apply Fin.case0.
108-
- now apply Fin.caseS'.
111+
intros n p v a. induction v.
112+
- now apply Fin.case0.
113+
- now apply (Fin.caseS' p).
109114
Qed.
110115

111116
Lemma nth_replace_neq A: forall n p q, p <> q -> forall (v : t A n) a,
112117
nth (replace v q a) p = nth v p.
113118
Proof.
114-
intros n p q Hpq v a. induction v as [|b n v IH]; revert Hpq; pattern p.
115-
- apply Fin.case0.
116-
- apply Fin.caseS'; pattern q; apply Fin.caseS'; [easy..|].
119+
intros n p q Hpq v a.
120+
induction v as [|b n v IH]; revert Hpq.
121+
- now apply Fin.case0.
122+
- apply (Fin.caseS' p); apply (Fin.caseS' q); [easy..|].
117123
intros ???. apply IH. intros ?. now subst.
118124
Qed.
119125

@@ -171,7 +177,7 @@ Lemma replace_append_L A: forall n m (v : t A n) (w : t A m) p a,
171177
replace (v ++ w) (Fin.L m p) a = (replace v p a) ++ w.
172178
Proof.
173179
intros n m v w p a. induction v as [|b n v IH].
174-
- pattern p. apply Fin.case0.
180+
- now apply Fin.case0.
175181
- apply (Fin.caseS' p).
176182
+ reflexivity.
177183
+ intros p'. cbn. apply f_equal, IH.
@@ -256,9 +262,10 @@ Qed.
256262
Lemma map2_ext A B C: forall (f g:A->B->C), (forall a b, f a b = g a b) ->
257263
forall n (v : t A n) (w : t B n), map2 f v w = map2 g v w.
258264
Proof.
259-
intros f g Hfg n v w. pattern n, v, w. apply rect2.
265+
intros f g Hfg n v w.
266+
apply (fun P H1 H2 => rect2 P H1 H2 v w).
260267
- reflexivity.
261-
- cbn. congruence.
268+
- cbn. intros ??? IH ??. now rewrite IH, Hfg.
262269
Qed.
263270

264271
(** ** Properties of [fold_left] *)
@@ -448,7 +455,7 @@ intros P n v1 v2. split.
448455
- intros H. induction H.
449456
+ apply Fin.case0.
450457
+ intros p. now apply (Fin.caseS' p).
451-
- pattern n, v1, v2. apply rect2.
458+
- apply (fun P H1 H2 => rect2 P H1 H2 v1 v2).
452459
+ constructor.
453460
+ intros ??? IH ?? H. constructor.
454461
* apply (H Fin.F1).

0 commit comments

Comments
 (0)