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
iotaDlm1 m2 n : iota (m1 + m2) n = map (addn m1) (iota m2 n). Proof. by elim: n m2 => //= n IHn m2; rewrite -addnS IHn. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
iotaDl
nth_iotap m n i : i < n -> nth p (iota m n) i = m + i. Proof. by move/subnKC <-; rewrite addSnnS iotaD nth_cat size_iota ltnn subnn. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
nth_iota
mem_iotam n i : (i \in iota m n) = (m <= i < m + n). Proof. elim: n m => [|n IHn] /= m; first by rewrite addn0 ltnNge andbN. by rewrite in_cons IHn addnS ltnS; case: ltngtP => // ->; rewrite leq_addr. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
mem_iota
iota_uniqm n : uniq (iota m n). Proof. by elim: n m => //= n IHn m; rewrite mem_iota ltnn /=. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
iota_uniq
take_iotak m n : take k (iota m n) = iota m (minn k n). Proof. have [lt_k_n|le_n_k] := ltnP. by elim: k n lt_k_n m => [|k IHk] [|n] //= H m; rewrite IHk. by apply: take_oversize; rewrite size_iota. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
take_iota
drop_iotak m n : drop k (iota m n) = iota (m + k) (n - k). Proof. by elim: k m n => [|k IHk] m [|n] //=; rewrite ?addn0 // IHk addnS subSS. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
drop_iota
filter_iota_ltnm n j : j <= n -> [seq i <- iota m n | i < m + j] = iota m j. Proof. elim: n m j => [m j|n IHn m [|j] jlen]; first by rewrite leqn0 => /eqP ->. rewrite (@eq_in_filter _ _ pred0) ?filter_pred0// => i. by rewrite addn0 ltnNge mem_iota => /andP[->]. by rewrite /= addnS leq_addr -addSn IHn. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
filter_iota_ltn
filter_iota_leqn m j : j < n -> [seq i <- iota m n | i <= m + j] = iota m j.+1. Proof. elim: n m j => [//|n IHn] m [|j] jlen /=; rewrite leq_addr. rewrite (@eq_in_filter _ _ pred0) ?filter_pred0// => i. by rewrite addn0 leqNgt mem_iota => /andP[->]. by rewrite addnS -addSn IHn -1?ltnS. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
filter_iota_leq
mkseqf n : seq T := map f (iota 0 n).
Definition
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
mkseq
size_mkseqf n : size (mkseq f n) = n. Proof. by rewrite size_map size_iota. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
size_mkseq
mkseqSf n : mkseq f n.+1 = rcons (mkseq f n) (f n). Proof. by rewrite /mkseq -addn1 iotaD add0n map_cat cats1. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
mkseqS
eq_mkseqf g : f =1 g -> mkseq f =1 mkseq g. Proof. by move=> Efg n; apply: eq_map Efg _. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
eq_mkseq
nth_mkseqf n i : i < n -> nth x0 (mkseq f n) i = f i. Proof. by move=> Hi; rewrite (nth_map 0) ?nth_iota ?size_iota. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
nth_mkseq
mkseq_nths : mkseq (nth x0 s) (size s) = s. Proof. by apply: (@eq_from_nth _ x0); rewrite size_mkseq // => i Hi; rewrite nth_mkseq. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
mkseq_nth
mkseq_specs : seq T -> Type := | MapIota n f : s = mkseq f n -> mkseq_spec s (mkseq f n).
Variant
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
mkseq_spec
mkseqPs : mkseq_spec s s. Proof. by rewrite -[s]mkseq_nth; constructor. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
mkseqP
map_nth_iota0s i : i <= size s -> [seq nth x0 s j | j <- iota 0 i] = take i s. Proof. by move=> ile; rewrite -[s in RHS]mkseq_nth -map_take take_iota (minn_idPl _). Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
map_nth_iota0
map_nth_iotas i j : j <= size s - i -> [seq nth x0 s k | k <- iota i j] = take j (drop i s). Proof. elim: i => [|i IH] in s j *; first by rewrite subn0 drop0 => /map_nth_iota0->. case: s => [|x s /IH<-]; first by rewrite leqn0 => /eqP->. by rewrite -add1n iotaDl -map_comp. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
map_nth_iota
mkseq_uniqP(f : nat -> T) n : reflect {in gtn n &, injective f} (uniq (mkseq f n)). Proof. apply: (equivP (uniqP (f 0))); rewrite size_mkseq. by split=> injf i j lti ltj; have:= injf i j lti ltj; rewrite !nth_mkseq. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
mkseq_uniqP
mkseq_uniq(f : nat -> T) n : injective f -> uniq (mkseq f n). Proof. by move/map_inj_uniq->; apply: iota_uniq. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
mkseq_uniq
perm_iotaP{s t : seq T} x0 (It := iota 0 (size t)) : reflect (exists2 Is, perm_eq Is It & s = map (nth x0 t) Is) (perm_eq s t). Proof. apply: (iffP idP) => [Est | [Is eqIst ->]]; last first. by rewrite -{2}[t](mkseq_nth x0) perm_map. elim: t => [|x t IHt] in s It Est *. by rewrite (perm_small_eq _ Est) //; exists [::]. have /rot_to[k s1 Ds]: x \in s by rewrite (perm_mem Est) mem_head. have [|Is1 eqIst1 Ds1] := IHt s1; first by rewrite -(perm_cons x) -Ds perm_rot. exists (rotr k (0 :: map succn Is1)). by rewrite perm_rot /It /= perm_cons (iotaDl 1) perm_map. by rewrite map_rotr /= -map_comp -(@eq_map _ _ (nth x0 t)) // -Ds1 -Ds rotK. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
perm_iotaP
foldrs := if s is x :: s' then f x (foldr s') else z0.
Fixpoint
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
foldr
foldr_cats1 s2 : foldr f z0 (s1 ++ s2) = foldr f (foldr f z0 s2) s1. Proof. by elim: s1 => //= x s1 ->. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
foldr_cat
foldr_rconss x : foldr f z0 (rcons s x) = foldr f (f x z0) s. Proof. by rewrite -cats1 foldr_cat. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
foldr_rcons
foldr_maps : foldr f z0 (map h s) = foldr (fun x z => f (h x) z) z0 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
foldr_map
sumn:= foldr addn 0.
Definition
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn
sumn_nconsx n s : sumn (ncons n x s) = x * n + sumn s. Proof. by rewrite mulnC; elim: n => //= n ->; rewrite addnA. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_ncons
sumn_nseqx n : sumn (nseq n x) = x * n. Proof. by rewrite sumn_ncons addn0. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_nseq
sumn_cats1 s2 : sumn (s1 ++ s2) = sumn s1 + sumn s2. Proof. by elim: s1 => //= x s1 ->; rewrite addnA. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_cat
sumn_countT (a : pred T) s : sumn [seq a i : nat | i <- s] = count a s. Proof. by elim: s => //= s0 s /= ->. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_count
sumn_rconss n : sumn (rcons s n) = sumn s + n. Proof. by rewrite -cats1 sumn_cat /= addn0. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_rcons
perm_sumns1 s2 : perm_eq s1 s2 -> sumn s1 = sumn s2. Proof. by apply/catCA_perm_subst: s1 s2 => s1 s2 s3; rewrite !sumn_cat addnCA. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
perm_sumn
sumn_rots n : sumn (rot n s) = sumn s. Proof. by apply/perm_sumn; rewrite perm_rot. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_rot
sumn_revs : sumn (rev s) = sumn s. Proof. by apply/perm_sumn; rewrite perm_rev. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_rev
natnseq0Ps : reflect (s = nseq (size s) 0) (sumn s == 0). Proof. apply: (iffP idP) => [|->]; last by rewrite sumn_nseq. by elim: s => //= x s IHs; rewrite addn_eq0 => /andP[/eqP-> /IHs <-]. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
natnseq0P
sumn_set_nths x0 n x : sumn (set_nth x0 s n x) = sumn s + x - (nth x0 s n) * (n < size s) + x0 * (n - size s). Proof. rewrite set_nthE; case: ltnP => [nlts|nges]; last first. by rewrite sumn_cat sumn_ncons /= addn0 muln0 subn0 addnAC addnA. have -> : n - size s = 0 by apply/eqP; rewrite subn_eq0 ltnW. rewrite -[in sumn s](cat_take_drop n s) [drop n s](drop_nth x0)//. by rewrite !sumn_cat /= muln1 muln0 addn0 addnAC !addnA [in RHS]addnAC addnK. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_set_nth
sumn_set_nth_ltns x0 n x : n < size s -> sumn (set_nth x0 s n x) = sumn s + x - nth x0 s n. Proof. move=> nlts; rewrite sumn_set_nth nlts muln1. have -> : n - size s = 0 by apply/eqP; rewrite subn_eq0 ltnW. by rewrite muln0 addn0. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_set_nth_ltn
sumn_set_nth0s n x : sumn (set_nth 0 s n x) = sumn s + x - nth 0 s n. Proof. rewrite sumn_set_nth mul0n addn0. by case: ltnP => [_|nges]; rewrite ?muln1// nth_default. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
sumn_set_nth0
foldlz s := if s is x :: s' then foldl (f z x) s' else z.
Fixpoint
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
foldl
foldl_revz s : foldl z (rev s) = foldr (fun x z => f z x) z s. Proof. by elim/last_ind: s z => // s x IHs z; rewrite rev_rcons -cats1 foldr_cat -IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
foldl_rev
foldl_catz s1 s2 : foldl z (s1 ++ s2) = foldl (foldl z s1) s2. Proof. by rewrite -(revK (s1 ++ s2)) foldl_rev rev_cat foldr_cat -!foldl_rev !revK. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
foldl_cat
foldl_rconsz s x : foldl z (rcons s x) = f (foldl z s) x. Proof. by rewrite -cats1 foldl_cat. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
foldl_rcons
foldl_foldrx0 l : foldl f x0 l = foldr f x0 l. Proof. elim: l x0 => [//|x1 l IHl] x0 /=; rewrite {}IHl. by elim: l x0 x1 => [//|x2 l IHl] x0 x1 /=; rewrite IHl !fA [f x2 x1]fC. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
foldl_foldr
pairmapx s := if s is y :: s' then f x y :: pairmap y s' else [::].
Fixpoint
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
pairmap
size_pairmapx s : size (pairmap x s) = size 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
size_pairmap
pairmap_catx s1 s2 : pairmap x (s1 ++ s2) = pairmap x s1 ++ pairmap (last x s1) s2. Proof. by elim: s1 x => //= y s1 IHs1 x; rewrite IHs1. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
pairmap_cat
nth_pairmaps n : n < size s -> forall x, nth x2 (pairmap x s) n = f (nth x1 (x :: s) n) (nth x1 s n). Proof. by elim: s n => [|y s IHs] [|n] //= Hn x; apply: IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
nth_pairmap
scanlx s := if s is y :: s' then let x' := g x y in x' :: scanl x' s' else [::].
Fixpoint
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
scanl
size_scanlx s : size (scanl x s) = size 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
size_scanl
scanl_catx s1 s2 : scanl x (s1 ++ s2) = scanl x s1 ++ scanl (foldl g x s1) s2. Proof. by elim: s1 x => //= y s1 IHs1 x; rewrite IHs1. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
scanl_cat
scanl_rconsx s1 y : scanl x (rcons s1 y) = rcons (scanl x s1) (foldl g x (rcons s1 y)). Proof. by rewrite -!cats1 scanl_cat foldl_cat. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
scanl_rcons
nth_cons_scanls n : n <= size s -> forall x, nth x1 (x :: scanl x s) n = foldl g x (take n s). Proof. by elim: s n => [|y s IHs] [|n] Hn x //=; rewrite IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
nth_cons_scanl
nth_scanls n : n < size s -> forall x, nth x1 (scanl x s) n = foldl g x (take n.+1 s). Proof. by move=> n_lt x; rewrite -nth_cons_scanl. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
nth_scanl
scanlK: (forall x, cancel (g x) (f x)) -> forall x, cancel (scanl x) (pairmap x). Proof. by move=> Hfg x s; elim: s x => //= y s IHs x; rewrite Hfg IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
scanlK
pairmapK: (forall x, cancel (f x) (g x)) -> forall x, cancel (pairmap x) (scanl x). Proof. by move=> Hgf x s; elim: s x => //= y s IHs x; rewrite Hgf IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
pairmapK
zip(s : seq S) (t : seq T) {struct t} := match s, t with | x :: s', y :: t' => (x, y) :: zip s' t' | _, _ => [::] end.
Fixpoint
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
zip
unzip1:= map (@fst S T).
Definition
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
unzip1
unzip2:= map (@snd S T).
Definition
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
unzip2
all2s t := match s, t with | [::], [::] => true | x :: s, y :: t => r x y && all2 s t | _, _ => false end.
Fixpoint
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
all2
zip_unzips : zip (unzip1 s) (unzip2 s) = s. Proof. by elim: s => [|[x y] s /= ->]. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
zip_unzip
unzip1_zips t : size s <= size t -> unzip1 (zip s t) = s. Proof. by elim: s t => [|x s IHs] [|y t] //= le_s_t; rewrite IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
unzip1_zip
unzip2_zips t : size t <= size s -> unzip2 (zip s t) = t. Proof. by elim: s t => [|x s IHs] [|y t] //= le_t_s; rewrite IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
unzip2_zip
size1_zips t : size s <= size t -> size (zip s t) = size s. Proof. by elim: s t => [|x s IHs] [|y t] //= Hs; rewrite IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
size1_zip
size2_zips t : size t <= size s -> size (zip s t) = size t. Proof. by elim: s t => [|x s IHs] [|y t] //= Hs; rewrite IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
size2_zip
size_zips t : size (zip s t) = minn (size s) (size t). Proof. by elim: s t => [|x s IHs] [|t2 t] //=; rewrite IHs minnSS. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
size_zip
zip_cats1 s2 t1 t2 : size s1 = size t1 -> zip (s1 ++ s2) (t1 ++ t2) = zip s1 t1 ++ zip s2 t2. Proof. by move: s1 t1; apply: seq_ind2 => //= x y s1 t1 _ ->. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
zip_cat
nth_zipx y s t i : size s = size t -> nth (x, y) (zip s t) i = (nth x s i, nth y t i). Proof. by elim: i s t => [|i IHi] [|y1 s1] [|y2 t] //= [/IHi->]. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
nth_zip
nth_zip_condp s t i : nth p (zip s t) i = (if i < size (zip s t) then (nth p.1 s i, nth p.2 t i) else p). Proof. rewrite size_zip ltnNge geq_min. by elim: s t i => [|x s IHs] [|y t] [|i] //=; rewrite ?orbT -?IHs. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
nth_zip_cond
zip_rconss t x y : size s = size t -> zip (rcons s x) (rcons t y) = rcons (zip s t) (x, y). Proof. by move=> eq_sz; rewrite -!cats1 zip_cat //= eq_sz. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
zip_rcons
rev_zips t : size s = size t -> rev (zip s t) = zip (rev s) (rev t). Proof. move: s t; apply: seq_ind2 => //= x y s t eq_sz IHs. by rewrite !rev_cons IHs zip_rcons ?size_rev. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
rev_zip
all2Es t : all2 s t = (size s == size t) && all [pred xy | r xy.1 xy.2] (zip s t). Proof. by elim: s t => [|x s IHs] [|y t] //=; rewrite IHs andbCA. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
all2E
zip_mapI f g (s : seq I) : zip (map f s) (map g s) = [seq (f i, g i) | i <- s]. Proof. by elim: s => //= i s ->. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
zip_map
unzip1_map_nth_zipx y s t l : size s = size t -> unzip1 [seq nth (x, y) (zip s t) i | i <- l] = [seq nth x s i | i <- l]. Proof. by move=> st; elim: l => [//=|n l IH /=]; rewrite nth_zip ?IH ?st. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
unzip1_map_nth_zip
unzip2_map_nth_zipx y s t l : size s = size t -> unzip2 [seq nth (x, y) (zip s t) i | i <- l] = [seq nth y t i | i <- l]. Proof. by move=> st; elim: l => [//=|n l IH /=]; rewrite nth_zip ?IH ?st. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
unzip2_map_nth_zip
zip_uniql(S T : eqType) (s : seq S) (t : seq T) : uniq s -> uniq (zip s t). Proof. case: s t => [|s0 s] [|t0 t] //; apply: contraTT => /(uniqPn (s0, t0)) [i [j]]. case=> o z; rewrite !nth_zip_cond !ifT ?js ?(ltn_trans o)// => -[n _]. by apply/(uniqPn s0); exists i, j; rewrite o n (leq_trans z) ?size_zip?geq_minl. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
zip_uniql
zip_uniqr(S T : eqType) (s : seq S) (t : seq T) : uniq t -> uniq (zip s t). Proof. case: s t => [|s0 s] [|t0 t] //; apply: contraTT => /(uniqPn (s0, t0)) [i [j]]. case=> o z; rewrite !nth_zip_cond !ifT ?js ?(ltn_trans o)// => -[_ n]. by apply/(uniqPn t0); exists i, j; rewrite o n (leq_trans z) ?size_zip?geq_minr. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
zip_uniqr
perm_zip_sym(S T : eqType) (s1 s2 : seq S) (t1 t2 : seq T) : perm_eq (zip s1 t1) (zip s2 t2) -> perm_eq (zip t1 s1) (zip t2 s2). Proof. have swap t s : zip t s = map (fun u => (u.2, u.1)) (zip s t). by elim: s t => [|x s +] [|y t]//= => ->. by rewrite [zip t1 s1]swap [zip t2 s2]swap; apply: perm_map. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
perm_zip_sym
perm_zip1{S T : eqType} (t1 t2 : seq T) (s1 s2 : seq S): size s1 = size t1 -> size s2 = size t2 -> perm_eq (zip s1 t1) (zip s2 t2) -> perm_eq s1 s2. Proof. wlog [x y] : s1 s2 t1 t2 / (S * T)%type => [hwlog|]. case: s2 t2 => [|x s2] [|y t2] //; last exact: hwlog. by case: s1 t1 => [|u s1] [|v t1]//= _ _ /perm_nilP. move=> eq1 eq2 /(perm_iotaP (x, y))[ns nsP /(congr1 (@unzip1 _ _))]. rewrite unzip1_zip ?unzip1_map_nth_zip -?eq1// => ->. by apply/(perm_iotaP x); exists ns; rewrite // size_zip -eq2 minnn in nsP. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
perm_zip1
perm_zip2{S T : eqType} (s1 s2 : seq S) (t1 t2 : seq T) : size s1 = size t1 -> size s2 = size t2 -> perm_eq (zip s1 t1) (zip s2 t2) -> perm_eq t1 t2. Proof. by move=> ? ? ?; rewrite (@perm_zip1 _ _ s1 s2) 1?perm_zip_sym. Qed. Prenex Implicits zip unzip1 unzip2 all2.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
perm_zip2
eqseq_all(T : eqType) (s t : seq T) : (s == t) = all2 eq_op s t. Proof. by elim: s t => [|x s +] [|y t]//= => <-. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
eqseq_all
eq_map_allI (T : eqType) (f g : I -> T) (s : seq I) : (map f s == map g s) = all [pred xy | xy.1 == xy.2] [seq (f i, g i) | i <- s]. Proof. by rewrite eqseq_all all2E !size_map eqxx zip_map. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
eq_map_all
flatten:= foldr cat (Nil T).
Definition
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
flatten
shape:= map (@size T).
Definition
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
shape
reshapesh s := if sh is n :: sh' then take n s :: reshape sh' (drop n s) else [::].
Fixpoint
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
reshape
flatten_indexsh r c := sumn (take r sh) + c.
Definition
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
flatten_index
reshape_indexsh i := find (pred1 0) (scanl subn i.+1 sh).
Definition
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
reshape_index
reshape_offsetsh i := i - sumn (take (reshape_index sh i) sh).
Definition
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
reshape_offset
size_flattenss : size (flatten ss) = sumn (shape ss). Proof. by elim: ss => //= s ss <-; rewrite size_cat. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
size_flatten
flatten_catss1 ss2 : flatten (ss1 ++ ss2) = flatten ss1 ++ flatten ss2. Proof. by elim: ss1 => //= s ss1 ->; rewrite catA. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
flatten_cat
size_reshapesh s : size (reshape sh s) = size sh. Proof. by elim: sh s => //= s0 sh IHsh s; rewrite IHsh. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
size_reshape
nth_reshape(sh : seq nat) l n : nth [::] (reshape sh l) n = take (nth 0 sh n) (drop (sumn (take n sh)) l). Proof. elim: n sh l => [| n IHn] [| sh0 sh] l; rewrite ?take0 ?drop0 //=. by rewrite addnC -drop_drop; apply: IHn. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
nth_reshape
flattenKss : reshape (shape ss) (flatten ss) = ss. Proof. by elim: ss => //= s ss IHss; rewrite take_size_cat ?drop_size_cat ?IHss. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
flattenK
reshapeKrsh s : size s <= sumn sh -> flatten (reshape sh s) = s. Proof. elim: sh s => [[]|n sh IHsh] //= s sz_s; rewrite IHsh ?cat_take_drop //. by rewrite size_drop leq_subLR. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
reshapeKr
reshapeKlsh s : size s >= sumn sh -> shape (reshape sh s) = sh. Proof. elim: sh s => [[]|n sh IHsh] //= s sz_s. rewrite size_takel; last exact: leq_trans (leq_addr _ _) sz_s. by rewrite IHsh // -(leq_add2l n) size_drop -maxnE leq_max sz_s orbT. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
reshapeKl
flatten_rconsss s : flatten (rcons ss s) = flatten ss ++ s. Proof. by rewrite -cats1 flatten_cat /= cats0. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
flatten_rcons
flatten_seq1s : flatten [seq [:: x] | x <- s] = s. Proof. by elim: s => //= s0 s ->. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
flatten_seq1
count_flattenss P : count P (flatten ss) = sumn [seq count P x | x <- ss]. Proof. by elim: ss => //= s ss IHss; rewrite count_cat IHss. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
count_flatten
filter_flattenss (P : pred T) : filter P (flatten ss) = flatten [seq filter P i | i <- ss]. Proof. by elim: ss => // s ss /= <-; apply: filter_cat. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
filter_flatten
rev_flattenss : rev (flatten ss) = flatten (rev (map rev ss)). Proof. by elim: ss => //= s ss IHss; rewrite rev_cons flatten_rcons -IHss rev_cat. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
rev_flatten
nth_shapess i : nth 0 (shape ss) i = size (nth [::] ss i). Proof. rewrite /shape; case: (ltnP i (size ss)) => Hi; first exact: nth_map. by rewrite !nth_default // size_map. Qed.
Lemma
boot
[ "From HB Require Import structures", "From mathcomp Require Import ssreflect ssrfun ssrbool eqtype ssrnat" ]
boot/seq.v
nth_shape