fact stringlengths 8 1.54k | type stringclasses 19 values | library stringclasses 8 values | imports listlengths 1 10 | filename stringclasses 98 values | symbolic_name stringlengths 1 42 | docstring stringclasses 1 value |
|---|---|---|---|---|---|---|
count_remP s : count P (rem s) = count P s - (x \in s) && P x.
Proof.
have [/perm_to_rem/permP->|xNs]/= := boolP (x \in s); first by rewrite addKn.
by rewrite subn0 rem_id.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | count_rem | |
count_mem_remy s : count_mem y (rem s) = count_mem y s - (x == y).
Proof.
rewrite count_rem; have []//= := boolP (x \in s).
by case: eqP => // <- /count_memPn->.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | count_mem_rem | |
maps := if s is x :: s' then f x :: map s' else [::]. | Fixpoint | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map | |
map_consx s : map (x :: s) = f x :: map s.
Proof. by []. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_cons | |
map_nseqx : map (nseq n0 x) = nseq n0 (f x).
Proof. by elim: n0 => // *; congr (_ :: _). Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_nseq | |
map_cats1 s2 : map (s1 ++ s2) = map s1 ++ map s2.
Proof. by elim: s1 => [|x s1 IHs] //=; rewrite IHs. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_cat | |
size_maps : size (map s) = size s.
Proof. by elim: s => //= x s ->. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | size_map | |
behead_maps : behead (map s) = map (behead s).
Proof. by case: s. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | behead_map | |
nth_mapn s : n < size s -> nth x2 (map s) n = f (nth x1 s n).
Proof. by elim: s n => [|x s IHs] []. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | nth_map | |
map_rconss x : map (rcons s x) = rcons (map s) (f x).
Proof. by rewrite -!cats1 map_cat. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_rcons | |
last_maps x : last (f x) (map s) = f (last x s).
Proof. by elim: s x => /=. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | last_map | |
belast_maps x : belast (f x) (map s) = map (belast x s).
Proof. by elim: s x => //= y s IHs x; rewrite IHs. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | belast_map | |
filter_mapa s : filter a (map s) = map (filter (preim f a) s).
Proof. by elim: s => //= x s IHs; rewrite (fun_if map) /= IHs. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | filter_map | |
find_mapa s : find a (map s) = find (preim f a) s.
Proof. by elim: s => //= x s ->. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | find_map | |
has_mapa s : has a (map s) = has (preim f a) s.
Proof. by elim: s => //= x s ->. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | has_map | |
all_mapa s : all a (map s) = all (preim f a) s.
Proof. by elim: s => //= x s ->. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | all_map | |
all_mapT(a : pred T2) s : (forall x, a (f x)) -> all a (map s).
Proof. by rewrite all_map => /allT->. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | all_mapT | |
count_mapa s : count a (map s) = count (preim f a) s.
Proof. by elim: s => //= x s ->. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | count_map | |
map_takes : map (take n0 s) = take n0 (map s).
Proof. by elim: n0 s => [|n IHn] [|x s] //=; rewrite IHn. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_take | |
map_drops : map (drop n0 s) = drop n0 (map s).
Proof. by elim: n0 s => [|n IHn] [|x s] //=; rewrite IHn. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_drop | |
map_rots : map (rot n0 s) = rot n0 (map s).
Proof. by rewrite /rot map_cat map_take map_drop. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_rot | |
map_rotrs : map (rotr n0 s) = rotr n0 (map s).
Proof. by apply: canRL (rotK n0) _; rewrite -map_rot rotrK. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_rotr | |
map_revs : map (rev s) = rev (map s).
Proof. by elim: s => //= x s IHs; rewrite !rev_cons -!cats1 map_cat IHs. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_rev | |
map_maskm s : map (mask m s) = mask m (map s).
Proof. by elim: m s => [|[|] m IHm] [|x p] //=; rewrite IHm. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_mask | |
inj_map: injective f -> injective map.
Proof. by move=> injf; elim=> [|x s IHs] [|y t] //= [/injf-> /IHs->]. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | inj_map | |
inj_in_map(A : {pred T1}) :
{in A &, injective f} -> {in [pred s | all [in A] s] &, injective map}.
Proof.
move=> injf; elim=> [|x s IHs] [|y t] //= /andP[Ax As] /andP[Ay At].
by case=> /injf-> // /IHs->.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | inj_in_map | |
onths n {struct n} : option T :=
if s isn't x :: s then None else
if n isn't n.+1 then Some x else onth s n. | Fixpoint | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onth | |
odflt_onthx0 s n : odflt x0 (onth s n) = nth x0 s n.
Proof. by elim: n s => [|? ?] []. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | odflt_onth | |
onthEs : onth s =1 nth None (map Some s).
Proof. by move=> n; elim: n s => [|? ?] []. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onthE | |
onth_nthx0 x t n : onth t n = Some x -> nth x0 t n = x.
Proof. by move=> tn; rewrite -odflt_onth tn. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onth_nth | |
onth0nn : onth [::] n = None. Proof. by case: n. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onth0n | |
onth1Px y n : onth [:: x] n = Some y <-> n = 0 /\ x = y.
Proof. by case: n => [|[]]; split=> // -[] // _ ->. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onth1P | |
onthTEs n : onth s n = (n < size s) :> bool.
Proof. by elim: n s => [|? ?] []. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onthTE | |
onthNEs n: ~~ onth s n = (size s <= n).
Proof. by rewrite onthTE -leqNgt. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onthNE | |
onth_defaultn s : size s <= n -> onth s n = None.
Proof. by rewrite -onthNE; case: onth. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onth_default | |
onth_cats1 s2 n :
onth (s1 ++ s2) n = if n < size s1 then onth s1 n else onth s2 (n - size s1).
Proof. by elim: n s1 => [|? ?] []. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onth_cat | |
onth_nseqx n m : onth (nseq n x) m = if m < n then Some x else None.
Proof. by rewrite onthE/= -nth_nseq map_nseq. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onth_nseq | |
eq_onthP{s1 s2} :
[<-> s1 = s2;
forall i : nat, i < maxn (size s1) (size s2) -> onth s1 i = onth s2 i;
forall i : nat, onth s1 i = onth s2 i].
Proof.
tfae=> [->//|eqs12 i|eqs12].
have := eqs12 i; case: ltnP => [_ ->//|].
by rewrite geq_max => /andP[is1 is2] _; rewrite !onth_default.
have /eqP eq_size_12 : size s1 == size s2.
by rewrite eqn_leq -!onthNE eqs12 onthNE -eqs12 onthNE !leqnn.
apply/(inj_map Some_inj)/(@eq_from_nth _ None); rewrite !size_map//.
by move=> i _; rewrite -!onthE eqs12.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | eq_onthP | |
eq_from_onth[s1 s2 : seq T] :
(forall i : nat, onth s1 i = onth s2 i) -> s1 = s2.
Proof. by move/(eq_onthP 0 2). Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | eq_from_onth | |
eq_from_onth_le[s1 s2 : seq T] :
(forall i : nat, i < maxn (size s1) (size s2) -> onth s1 i = onth s2 i) ->
s1 = s2.
Proof. by move/(eq_onthP 0 1). Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | eq_from_onth_le | |
onth_map{T S} n (s : seq T) (f : T -> S) :
onth (map f s) n = omap f (onth s n).
Proof. by elim: s n => [|x s IHs] []. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onth_map | |
inj_onth_map{T S} n (s : seq T) (f : T -> S) x :
injective f -> onth (map f s) n = Some (f x) -> onth s n = Some x.
Proof. by rewrite onth_map => /inj_omap + fs; apply. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | inj_onth_map | |
onthPs x : reflect (exists i, onth s i = Some x) (x \in s).
Proof.
elim: s => [|y s IHs]; first by constructor=> -[] [].
rewrite in_cons; case: eqVneq => [->|/= Nxy]; first by constructor; exists 0.
apply: (iffP idP) => [/IHs[i <-]|[[|i]//=]]; first by exists i.+1.
by move=> [eq_xy]; rewrite eq_xy eqxx in Nxy.
by move=> six; apply/IHs; exists i.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onthP | |
onthPns x : reflect (forall i, onth s i != Some x) (x \notin s).
Proof.
apply: (iffP idP); first by move=> /onthP + i; apply: contra_not_neq; exists i.
by move=> nsix; apply/onthP => -[n /eqP/negPn]; rewrite nsix.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onthPn | |
onth_injs n m : uniq s -> minn m n < size s ->
onth s n = onth s m -> n = m.
Proof.
elim: s m n => [|x s IHs]//= [|m] [|n]//=; rewrite ?minnSS !ltnS.
- by move=> /andP[+ _] _ /eqP => /onthPn/(_ _)/negPf->.
- by move=> /andP[+ _] _ /esym /eqP => /onthPn/(_ _)/negPf->.
by move=> /andP[xNs /IHs]/[apply]/[apply]->.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | onth_inj | |
filter_maskT a (s : seq T) : filter a s = mask (map a s) s.
Proof. by elim: s => //= x s <-; case: (a x). Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | filter_mask | |
all_sigPT a (s : seq T) : all a s -> {s' : seq (sig a) | s = map sval s'}.
Proof.
elim: s => /= [_|x s ihs /andP [ax /ihs [s' ->]]]; first by exists [::].
by exists (exist a x ax :: s').
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | all_sigP | |
leq_count_maskT (P : {pred T}) m s : count P (mask m s) <= count P s.
Proof.
by elim: s m => [|x s IHs] [|[] m]//=;
rewrite ?leq_add2l (leq_trans (IHs _)) ?leq_addl.
Qed.
Variable (T : eqType).
Implicit Types (s : seq T) (m : bitseq). | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | leq_count_mask | |
mask_filters m : uniq s -> mask m s = [seq i <- s | i \in mask m s].
Proof.
elim: m s => [|[] m IH] [|x s /= /andP[/negP xS uS]]; rewrite ?filter_pred0 //.
rewrite inE eqxx /=; congr cons; rewrite [LHS]IH//.
by apply/eq_in_filter => ? /[1!inE]; case: eqP => [->|].
by case: ifP => [/mem_mask //|_]; apply: IH.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | mask_filter | |
leq_count_subseqP s1 s2 : subseq s1 s2 -> count P s1 <= count P s2.
Proof. by move=> /subseqP[m _ ->]; rewrite leq_count_mask. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | leq_count_subseq | |
count_maskPs1 s2 :
(forall x, count_mem x s1 <= count_mem x s2) <->
exists2 m : bitseq, size m = size s2 & perm_eq s1 (mask m s2).
Proof.
split=> [s1_le|[m _ /permP s1ms2 x]]; last by rewrite s1ms2 leq_count_mask.
suff [m mP]: exists m, perm_eq s1 (mask m s2).
by have [m' sm' eqm] := resize_mask m s2; exists m'; rewrite -?eqm.
elim: s2 => [|x s2 IHs]//= in s1 s1_le *.
by exists [::]; apply/allP => x _/=; rewrite eqn_leq s1_le.
have [y|m s1s2] := IHs (rem x s1); first by rewrite count_mem_rem leq_subLR.
exists ((x \in s1) :: m); have [|/rem_id<-//] := boolP (x \in s1).
by move/perm_to_rem/permPl->; rewrite perm_cons.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | count_maskP | |
count_subseqPs1 s2 :
(forall x, count_mem x s1 <= count_mem x s2) <->
exists2 s, subseq s s2 & perm_eq s1 s.
Proof.
split=> [/count_maskP[m _]|]; first by exists (mask m s2); rewrite ?mask_subseq.
by move=> -[_/subseqP[m sm ->] ?]; apply/count_maskP; exists m.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | count_subseqP | |
filter_subseqa s : subseq (filter a s) s.
Proof. by apply/subseqP; exists (map a s); rewrite ?size_map ?filter_mask. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | filter_subseq | |
subseq_filters1 s2 a :
subseq s1 (filter a s2) = all a s1 && subseq s1 s2.
Proof.
elim: s2 s1 => [|x s2 IHs] [|y s1] //=; rewrite ?andbF ?sub0seq //.
by case a_x: (a x); rewrite /= !IHs /=; case: eqP => // ->; rewrite a_x.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | subseq_filter | |
subseq_uniqPs1 s2 :
uniq s2 -> reflect (s1 = filter [in s1] s2) (subseq s1 s2).
Proof.
move=> uniq_s2; apply: (iffP idP) => [ss12 | ->]; last exact: filter_subseq.
apply/eqP; rewrite -size_subseq_leqif ?subseq_filter ?(introT allP) //.
apply/eqP/esym/perm_size.
rewrite uniq_perm ?filter_uniq ?(subseq_uniq ss12) // => x.
by rewrite mem_filter; apply: andb_idr; apply: (mem_subseq ss12).
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | subseq_uniqP | |
uniq_subseq_pivotx (s1 s2 s3 s4 : seq T) (s := s3 ++ x :: s4) :
uniq s -> subseq (s1 ++ x :: s2) s = (subseq s1 s3 && subseq s2 s4).
Proof.
move=> uniq_s; apply/idP/idP => [sub_s'_s|/andP[? ?]]; last first.
by rewrite cat_subseq //= eqxx.
have uniq_s' := subseq_uniq sub_s'_s uniq_s.
have/eqP {sub_s'_s uniq_s} := subseq_uniqP _ uniq_s sub_s'_s.
rewrite !filter_cat /= mem_cat inE eqxx orbT /=.
rewrite uniq_eqseq_pivotl // => /andP [/eqP -> /eqP ->].
by rewrite !filter_subseq.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | uniq_subseq_pivot | |
perm_to_subseqs1 s2 :
subseq s1 s2 -> {s3 | perm_eq s2 (s1 ++ s3)}.
Proof.
elim Ds2: s2 s1 => [|y s2' IHs] [|x s1] //=; try by exists s2; rewrite Ds2.
case: eqP => [-> | _] /IHs[s3 perm_s2] {IHs}.
by exists s3; rewrite perm_cons.
by exists (rcons s3 y); rewrite -cat_cons -perm_rcons -!cats1 catA perm_cat2r.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | perm_to_subseq | |
subseq_remx : {homo rem x : s1 s2 / @subseq T s1 s2}.
Proof.
move=> s1 s2; elim: s2 s1 => [|x2 s2 IHs2] [|x1 s1]; rewrite ?sub0seq //=.
have [->|_] := eqVneq x1 x2; first by case: eqP => //= _ /IHs2; rewrite eqxx.
move=> /IHs2/subseq_trans->//.
by have [->|_] := eqVneq x x2; [apply: rem_subseq|apply: subseq_cons].
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | subseq_rem | |
map_fs x : x \in s -> f x \in map f s.
Proof.
by elim: s => //= y s IHs /predU1P[->|/IHs]; [apply: predU1l | apply: predU1r].
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_f | |
mapPs y : reflect (exists2 x, x \in s & y = f x) (y \in map f s).
Proof.
elim: s => [|x s IHs]; [by right; case|rewrite /= inE].
exact: equivP (orPP eqP IHs) (iff_sym exists_cons).
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | mapP | |
subset_mapP(s : seq T1) (s' : seq T2) :
{subset s' <= map f s} <-> exists2 t, all (mem s) t & s' = map f t.
Proof.
split => [|[r /allP/= rE ->] _ /mapP[x xr ->]]; last by rewrite map_f ?rE.
elim: s' => [|x s' IHs'] subss'; first by exists [::].
have /mapP[y ys ->] := subss' _ (mem_head _ _).
have [x' x's'|t st ->] := IHs'; first by rewrite subss'// inE x's' orbT.
by exists (y :: t); rewrite //= ys st.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | subset_mapP | |
map_uniqs : uniq (map f s) -> uniq s.
Proof.
elim: s => //= x s IHs /andP[not_sfx /IHs->]; rewrite andbT.
by apply: contra not_sfx => sx; apply/mapP; exists x.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_uniq | |
map_inj_in_uniqs : {in s &, injective f} -> uniq (map f s) = uniq s.
Proof.
elim: s => //= x s IHs //= injf; congr (~~ _ && _).
apply/mapP/idP=> [[y sy /injf] | ]; last by exists x.
by rewrite mem_head mem_behead // => ->.
by apply: IHs => y z sy sz; apply: injf => //; apply: predU1r.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_inj_in_uniq | |
map_subseqs1 s2 : subseq s1 s2 -> subseq (map f s1) (map f s2).
Proof.
case/subseqP=> m sz_m ->; apply/subseqP.
by exists m; rewrite ?size_map ?map_mask.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_subseq | |
nth_index_maps x0 x :
{in s &, injective f} -> x \in s -> nth x0 s (index (f x) (map f s)) = x.
Proof.
elim: s => //= y s IHs inj_f s_x; rewrite (inj_in_eq inj_f) ?mem_head //.
move: s_x; rewrite inE; have [-> // | _] := eqVneq; apply: IHs.
by apply: sub_in2 inj_f => z; apply: predU1r.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | nth_index_map | |
perm_maps t : perm_eq s t -> perm_eq (map f s) (map f t).
Proof. by move/permP=> Est; apply/permP=> a; rewrite !count_map Est. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | perm_map | |
sub_maps1 s2 : {subset s1 <= s2} -> {subset map f s1 <= map f s2}.
Proof. by move=> sub_s ? /mapP[x x_s ->]; rewrite map_f ?sub_s. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | sub_map | |
eq_mem_maps1 s2 : s1 =i s2 -> map f s1 =i map f s2.
Proof. by move=> Es x; apply/idP/idP; apply: sub_map => ?; rewrite Es. Qed.
Hypothesis Hf : injective f. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | eq_mem_map | |
mem_maps x : (f x \in map f s) = (x \in s).
Proof. by apply/mapP/idP=> [[y Hy /Hf->] //|]; exists x. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | mem_map | |
index_maps x : index (f x) (map f s) = index x s.
Proof. by rewrite /index; elim: s => //= y s IHs; rewrite (inj_eq Hf) IHs. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | index_map | |
map_inj_uniqs : uniq (map f s) = uniq s.
Proof. by apply: map_inj_in_uniq; apply: in2W. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_inj_uniq | |
undup_map_injs : undup (map f s) = map f (undup s).
Proof. by elim: s => //= s0 s ->; rewrite mem_map //; case: (_ \in _). Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | undup_map_inj | |
perm_map_injs t : perm_eq (map f s) (map f t) -> perm_eq s t.
Proof.
move/permP=> Est; apply/allP=> x _ /=.
have Dx: pred1 x =1 preim f (pred1 (f x)) by move=> y /=; rewrite inj_eq.
by rewrite !(eq_count Dx) -!count_map Est.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | perm_map_inj | |
map_of_seq(T1 : eqType) T2 (s : seq T1) (fs : seq T2) (y0 : T2) :
{f | uniq s -> size fs = size s -> map f s = fs}.
Proof.
exists (fun x => nth y0 fs (index x s)) => uAs eq_sz.
apply/esym/(@eq_from_nth _ y0); rewrite ?size_map eq_sz // => i ltis.
by have x0 : T1 by [case: (s) ltis]; rewrite (nth_map x0) // index_uniq.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_of_seq | |
map_id(s : seq T) : map id s = s.
Proof. by elim: s => //= x s ->. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_id | |
eq_map(f g : S -> T) : f =1 g -> map f =1 map g.
Proof. by move=> Ef; elim=> //= x s ->; rewrite Ef. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | eq_map | |
map_comp(f : T -> U) (g : S -> T) s : map (f \o g) s = map f (map g s).
Proof. by elim: s => //= x s ->. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_comp | |
mapK(f : S -> T) (g : T -> S) : cancel f g -> cancel (map f) (map g).
Proof. by move=> fK; elim=> //= x s ->; rewrite fK. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | mapK | |
mapK_in(A : {pred S}) (f : S -> T) (g : T -> S) :
{in A, cancel f g} -> {in [pred s | all [in A] s], cancel (map f) (map g)}.
Proof. by move=> fK; elim=> //= x s IHs /andP[/fK-> /IHs->]. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | mapK_in | |
eq_in_map(S : eqType) T (f g : S -> T) (s : seq S) :
{in s, f =1 g} <-> map f s = map g s.
Proof.
elim: s => //= x s IHs; split=> [/forall_cons[-> ?]|]; first by rewrite IHs.1.
by move=> -[? ?]; apply/forall_cons; split=> [//|]; apply: IHs.2.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | eq_in_map | |
map_id_in(T : eqType) f (s : seq T) : {in s, f =1 id} -> map f s = s.
Proof. by move/eq_in_map->; apply: map_id. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_id_in | |
pmaps :=
if s is x :: s' then let r := pmap s' in oapp (cons^~ r) r (f x) else [::]. | Fixpoint | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | pmap | |
map_pK: pcancel g f -> cancel (map g) pmap.
Proof. by move=> gK; elim=> //= x s ->; rewrite gK. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | map_pK | |
size_pmaps : size (pmap s) = count [eta f] s.
Proof. by elim: s => //= x s <-; case: (f _). Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | size_pmap | |
pmapS_filters : map some (pmap s) = map f (filter [eta f] s).
Proof. by elim: s => //= x s; case fx: (f x) => //= [u] <-; congr (_ :: _). Qed.
Hypothesis fK : ocancel f g. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | pmapS_filter | |
pmap_filters : map g (pmap s) = filter [eta f] s.
Proof. by elim: s => //= x s <-; rewrite -{3}(fK x); case: (f _). Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | pmap_filter | |
pmap_cats t : pmap (s ++ t) = pmap s ++ pmap t.
Proof. by elim: s => //= x s ->; case/f: x. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | pmap_cat | |
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. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | all_pmap | |
eq_in_pmap(aT : eqType) rT (f1 f2 : aT -> option rT) s :
{in s, f1 =1 f2} -> pmap f1 s = pmap f2 s.
Proof. by elim: s => //= a s IHs /forall_cons [-> /IHs ->]. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | eq_in_pmap | |
eq_pmapaT rT (f1 f2 : aT -> option rT) :
f1 =1 f2 -> pmap f1 =1 pmap f2.
Proof. by move=> Ef; elim => //= a s ->; rewrite Ef. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | eq_pmap | |
mem_pmaps u : (u \in pmap f s) = (Some u \in map f s).
Proof. by elim: s => //= x s IHs; rewrite in_cons -IHs; case: (f x). Qed.
Hypothesis fK : ocancel f g. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | mem_pmap | |
can2_mem_pmap: pcancel g f -> forall s u, (u \in pmap f s) = (g u \in s).
Proof.
by move=> gK s u; rewrite -(mem_map (pcan_inj gK)) pmap_filter // mem_filter gK.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | can2_mem_pmap | |
pmap_uniqs : uniq s -> uniq (pmap f s).
Proof. move/(filter_uniq f); rewrite -(pmap_filter fK); exact: map_uniq. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | pmap_uniq | |
perm_pmaps t : perm_eq s t -> perm_eq (pmap f s) (pmap f t).
Proof.
move=> eq_st; apply/(perm_map_inj Some_inj); rewrite !pmapS_filter.
exact/perm_map/perm_filter.
Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | perm_pmap | |
size_pmap_subs : size (pmap (insub : T -> option sT) s) = count p s.
Proof. by rewrite size_pmap (eq_count (isSome_insub _)). Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | size_pmap_sub | |
mem_pmap_subs u : (u \in pmap insT s) = (val u \in s).
Proof. exact/(can2_mem_pmap (insubK _))/valK. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | mem_pmap_sub | |
pmap_sub_uniqs : uniq s -> uniq (pmap insT s).
Proof. exact: (pmap_uniq (insubK _)). Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | pmap_sub_uniq | |
iotam n := if n is n'.+1 then m :: iota m.+1 n' else [::]. | Fixpoint | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | iota | |
size_iotam n : size (iota m n) = n.
Proof. by elim: n m => //= n IHn m; rewrite IHn. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | size_iota | |
iotaDm n1 n2 : iota m (n1 + n2) = iota m n1 ++ iota (m + n1) n2.
Proof. by elim: n1 m => [|n1 IHn1] m; rewrite ?addn0 // -addSnnS /= -IHn1. Qed. | Lemma | boot | [
"From HB Require Import structures",
"From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat"
] | boot/seq.v | iotaD |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.