diff options
| author | Kazuhiko Sakaguchi | 2019-11-15 01:05:32 +0900 |
|---|---|---|
| committer | Kazuhiko Sakaguchi | 2019-11-15 07:23:20 +0900 |
| commit | 6c78e2dbfda528a660c2b4d15294dc93c302c92c (patch) | |
| tree | 2da9af2ffd6bd8c7d2b392eba90b0fd82fb3129f /mathcomp/ssreflect | |
| parent | 45940df1c68ba8b4546c5ae0c7e464505a7f0ad6 (diff) | |
Add all_filter, all_pmap, and all_allpairsP in seq.v
Diffstat (limited to 'mathcomp/ssreflect')
| -rw-r--r-- | mathcomp/ssreflect/seq.v | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/mathcomp/ssreflect/seq.v b/mathcomp/ssreflect/seq.v index 35d9a69..57c9437 100644 --- a/mathcomp/ssreflect/seq.v +++ b/mathcomp/ssreflect/seq.v @@ -555,6 +555,10 @@ Proof. by move=> Ea s; rewrite !has_count (eq_count Ea). Qed. Lemma eq_all a1 a2 : a1 =1 a2 -> all a1 =1 all a2. Proof. by move=> Ea s; rewrite !all_count (eq_count Ea). Qed. +Lemma all_filter (p q : pred T) xs : + all p (filter q xs) = all [pred i | q i ==> p i] xs. +Proof. by elim: xs => //= x xs <-; case: (q x). Qed. + Section SubPred. Variable (a1 a2 : pred T). @@ -2260,6 +2264,10 @@ Proof. by elim: s => //= x s <-; rewrite -{3}(fK x); case: (f _). Qed. Lemma pmap_cat s t : pmap (s ++ t) = pmap s ++ pmap t. Proof. by elim: s => //= x s ->; case/f: x. Qed. +Lemma all_pmap (p : pred rT) s : + all p (pmap s) = all [pred i | oapp p true (f i)] s. +Proof. by elim: s => //= x s <-; case: f. Qed. + End Pmap. Section EqPmap. @@ -2922,6 +2930,8 @@ Qed. End EqAllPairsDep. +Arguments allpairsPdep {S T R f s t z}. + Section MemAllPairs. Variables (S : Type) (T : S -> Type) (R : eqType). @@ -2944,7 +2954,22 @@ Qed. End MemAllPairs. -Arguments allpairsPdep {S T R f s t z}. +Lemma all_allpairsP + (S : eqType) (T : S -> eqType) (R : Type) + (p : pred R) (f : forall x : S, T x -> R) + (s : seq S) (t : forall x : S, seq (T x)) : + reflect (forall (x : S) (y : T x), x \in s -> y \in t x -> p (f x y)) + (all p [seq f x y | x <- s, y <- t x]). +Proof. +elim: s => [|x s IHs]; first by constructor. +rewrite /= all_cat all_map /preim. +apply/(iffP andP)=> [[/allP /= ? ? x' y x'_in_xs]|p_xs_t]. + by move: x'_in_xs y; rewrite inE => /predU1P [-> //|? ?]; exact: IHs. +split; first by apply/allP => ?; exact/p_xs_t/mem_head. +by apply/IHs => x' y x'_in_s; apply: p_xs_t; rewrite inE x'_in_s orbT. +Qed. + +Arguments all_allpairsP {S T R p f s t}. Section EqAllPairs. |
