@@ -2848,14 +2848,30 @@ case/subseqP=> m sz_m ->; apply/subseqP.
28482848by exists m; rewrite ?size_map ?map_mask.
28492849Qed .
28502850
2851- Lemma nth_index_map s x0 x :
2852- {in s &, injective f} -> x \in s -> nth x0 s ( index (f x) (map f s)) = x .
2851+ Lemma index_map_in s x :
2852+ {in s &, injective f} -> x \in s -> index (f x) (map f s) = index x s .
28532853Proof .
2854- elim: s => //= y s IHs inj_f s_x; rewrite (inj_in_eq inj_f) ?mem_head //.
2855- move: s_x; rewrite inE; have [-> // | _] := eqVneq; apply: IHs.
2856- by apply: sub_in2 inj_f => z; apply: predU1r.
2854+ move=> f_inj x_in_s; rewrite /index find_map.
2855+ by apply: eq_in_find => y /= y_s; rewrite (inj_in_eq f_inj).
28572856Qed .
28582857
2858+ Lemma index_map_inW s x : {in s, injective f} -> index (f x) (map f s) = index x s.
2859+ Proof .
2860+ move=> fI; have [/index_map_in-> // _ _ _ _ /fI-> //|xs] := boolP (x \in s).
2861+ rewrite !memNindex ?size_map//; apply/mapP => -[y ys].
2862+ by move=> /esym/fI -/(_ ys) yx; rewrite -yx ys in xs.
2863+ Qed .
2864+
2865+ Lemma uniq_map_inj_in s : uniq (map f s) -> {in s &, injective f}.
2866+ Proof .
2867+ move=> f_uniq x y /(nthP x)[i ilt <-] /(nthP x)[j jlt <-].
2868+ by rewrite -!(nth_map _ (f x))// => /uniqP /[!(inE, size_map)] ->.
2869+ Qed .
2870+
2871+ Lemma nth_index_map s x0 x :
2872+ {in s &, injective f} -> x \in s -> nth x0 s (index (f x) (map f s)) = x.
2873+ Proof . by move=> f_inj x_in_s; rewrite index_map_in// nth_index. Qed .
2874+
28592875Lemma perm_map s t : perm_eq s t -> perm_eq (map f s) (map f t).
28602876Proof . by move/permP=> Est; apply/permP=> a; rewrite !count_map Est. Qed .
28612877
@@ -2871,7 +2887,7 @@ Lemma mem_map s x : (f x \in map f s) = (x \in s).
28712887Proof . by apply/mapP/idP=> [[y Hy /Hf->] //|]; exists x. Qed .
28722888
28732889Lemma index_map s x : index (f x) (map f s) = index x s.
2874- Proof . by rewrite /index; elim: s => //= y s IHs; rewrite (inj_eq Hf) IHs . Qed .
2890+ Proof . by apply: index_map_inW; apply: in1W . Qed .
28752891
28762892Lemma map_inj_uniq s : uniq (map f s) = uniq s.
28772893Proof . by apply: map_inj_in_uniq; apply: in2W. Qed .
@@ -3122,6 +3138,13 @@ case: s => [|x s /IH<-]; first by rewrite leqn0 => /eqP->.
31223138by rewrite -add1n iotaDl -map_comp.
31233139Qed .
31243140
3141+ Lemma take_mkseq f n i : take i (mkseq f n) = mkseq f (minn i n).
3142+ Proof . by rewrite /mkseq -map_take take_iota. Qed .
3143+
3144+ Lemma drop_mkseq f n i :
3145+ drop i (mkseq f n) = mkseq (fun k => f (i + k)) (n - i).
3146+ Proof . by rewrite /mkseq -map_drop drop_iota addnC iotaDl -map_comp. Qed .
3147+
31253148End MakeSeq.
31263149
31273150Section MakeEqSeq.
0 commit comments