statement
stringlengths
1
4.33k
proof
stringlengths
0
37.9k
type
stringclasses
25 values
symbolic_name
stringlengths
1
67
library
stringclasses
10 values
filename
stringclasses
112 values
imports
listlengths
2
138
deps
listlengths
0
64
docstring
stringclasses
798 values
source_url
stringclasses
1 value
commit
stringclasses
1 value
set_set_nth s n1 y1 n2 y2 (s2 := set_nth s n2 y2) : set_nth (set_nth s n1 y1) n2 y2 = if n1 == n2 then s2 else set_nth s2 n1 y1.
Proof. have [-> | ne_n12] := eqVneq. apply: eq_from_nth => [|i _]; first by rewrite !size_set_nth maxnA maxnn. by do 2!rewrite !nth_set_nth /=; case: eqP. apply: eq_from_nth => [|i _]; first by rewrite !size_set_nth maxnCA. by do 2!rewrite !nth_set_nth /=; case: eqP => // ->; case: eqVneq ne_n12. Qed.
Lemma
set_set_nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "eqVneq", "eq_from_nth", "maxnA", "maxnCA", "maxnn", "nth_set_nth", "s2", "set_nth", "size_set_nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
find s
:= if s is x :: s' then if a x then 0 else (find s').+1 else 0.
Fixpoint
find
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter s
:= if s is x :: s' then if a x then x :: filter s' else filter s' else [::].
Fixpoint
filter
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count s
:= if s is x :: s' then a x + count s' else 0.
Fixpoint
count
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has s
:= if s is x :: s' then a x || has s' else false.
Fixpoint
has
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all s
:= if s is x :: s' then a x && all s' else true.
Fixpoint
all
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_filter s : size (filter s) = count s.
Proof. by elim: s => //= x s <-; case (a x). Qed.
Lemma
size_filter
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count", "filter", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_count s : has s = (0 < count s).
Proof. by elim: s => //= x s ->; case (a x). Qed.
Lemma
has_count
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count", "has" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_filter_gt0 s : (size (filter s) > 0) = (has s).
Proof. by rewrite size_filter -has_count. Qed.
Lemma
size_filter_gt0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "filter", "has", "has_count", "size", "size_filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_size s : count s <= size s.
Proof. by elim: s => //= x s; case: (a x); last apply: leqW. Qed.
Lemma
count_size
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "count", "last", "leqW", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_count s : all s = (count s == size s).
Proof. elim: s => //= x s; case: (a x) => _ //=. by rewrite add0n eqn_leq andbC ltnNge count_size. Qed.
Lemma
all_count
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "add0n", "all", "count", "count_size", "eqn_leq", "ltnNge", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_all s : all (filter s).
Proof. by elim: s => //= x s IHs; case: ifP => //= ->. Qed.
Lemma
filter_all
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_filterP s : reflect (filter s = s) (all s).
Proof. apply: (iffP idP) => [| <-]; last exact: filter_all. by elim: s => //= x s IHs /andP[-> Hs]; rewrite IHs. Qed.
Lemma
all_filterP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "apply", "filter", "filter_all", "last" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_id s : filter (filter s) = filter s.
Proof. by apply/all_filterP; apply: filter_all. Qed.
Lemma
filter_id
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_filterP", "apply", "filter", "filter_all" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_find s : has s = (find s < size s).
Proof. by elim: s => //= x s IHs; case (a x); rewrite ?leqnn. Qed.
Lemma
has_find
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "has", "leqnn", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
find_size s : find s <= size s.
Proof. by elim: s => //= x s IHs; case (a x). Qed.
Lemma
find_size
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
find_cat s1 s2 : find (s1 ++ s2) = if has s1 then find s1 else size s1 + find s2.
Proof. by elim: s1 => //= x s1 IHs; case: (a x) => //; rewrite IHs (fun_if succn). Qed.
Lemma
find_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "has", "s1", "s2", "size", "succn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_nil : has [::] = false.
Proof. by []. Qed.
Lemma
has_nil
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "has" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_seq1 x : has [:: x] = a x.
Proof. exact: orbF. Qed.
Lemma
has_seq1
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "has" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_nseq n x : has (nseq n x) = (0 < n) && a x.
Proof. by elim: n => //= n ->; apply: andKb. Qed.
Lemma
has_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "andKb", "apply", "has", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_seqb (b : bool) x : has (nseq b x) = b && a x.
Proof. by rewrite has_nseq lt0b. Qed.
Lemma
has_seqb
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "has", "has_nseq", "lt0b", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_nil : all [::] = true.
Proof. by []. Qed.
Lemma
all_nil
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_seq1 x : all [:: x] = a x.
Proof. exact: andbT. Qed.
Lemma
all_seq1
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_nseq n x : all (nseq n x) = (n == 0) || a x.
Proof. by elim: n => //= n ->; apply: orKb. Qed.
Lemma
all_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "apply", "nseq", "orKb" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_nseqb (b : bool) x : all (nseq b x) = b ==> a x.
Proof. by rewrite all_nseq eqb0 implybE. Qed.
Lemma
all_nseqb
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all_nseq", "eqb0", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_nseq n x : filter (nseq n x) = nseq (a x * n) x.
Proof. by elim: n => /= [|n ->]; case: (a x). Qed.
Lemma
filter_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "filter", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_nseq n x : count (nseq n x) = a x * n.
Proof. by rewrite -size_filter filter_nseq size_nseq. Qed.
Lemma
count_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count", "filter_nseq", "nseq", "size_filter", "size_nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
find_nseq n x : find (nseq n x) = ~~ a x * n.
Proof. by elim: n => /= [|n ->]; case: (a x). Qed.
Lemma
find_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_find s : has s -> a (nth s (find s)).
Proof. by elim: s => //= x s IHs; case a_x: (a x). Qed.
Lemma
nth_find
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "has", "nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
before_find s i : i < find s -> a (nth s i) = false.
Proof. by elim: s i => //= x s IHs; case: ifP => // a'x [|i] // /(IHs i). Qed.
Lemma
before_find
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
hasNfind s : ~~ has s -> find s = size s.
Proof. by rewrite has_find; case: ltngtP (find_size s). Qed.
Lemma
hasNfind
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "find_size", "has", "has_find", "ltngtP", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_cat s1 s2 : filter (s1 ++ s2) = filter s1 ++ filter s2.
Proof. by elim: s1 => //= x s1 ->; case (a x). Qed.
Lemma
filter_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "filter", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_rcons s x : filter (rcons s x) = if a x then rcons (filter s) x else filter s.
Proof. by rewrite -!cats1 filter_cat /=; case (a x); rewrite /= ?cats0. Qed.
Lemma
filter_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cats0", "cats1", "filter", "filter_cat", "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_cat s1 s2 : count (s1 ++ s2) = count s1 + count s2.
Proof. by rewrite -!size_filter filter_cat size_cat. Qed.
Lemma
count_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count", "filter_cat", "s1", "s2", "size_cat", "size_filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_cat s1 s2 : has (s1 ++ s2) = has s1 || has s2.
Proof. by elim: s1 => [|x s1 IHs] //=; rewrite IHs orbA. Qed.
Lemma
has_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "has", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_rcons s x : has (rcons s x) = a x || has s.
Proof. by rewrite -cats1 has_cat has_seq1 orbC. Qed.
Lemma
has_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cats1", "has", "has_cat", "has_seq1", "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_cat s1 s2 : all (s1 ++ s2) = all s1 && all s2.
Proof. by elim: s1 => [|x s1 IHs] //=; rewrite IHs andbA. Qed.
Lemma
all_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_rcons s x : all (rcons s x) = a x && all s.
Proof. by rewrite -cats1 all_cat all_seq1 andbC. Qed.
Lemma
all_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all_cat", "all_seq1", "cats1", "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
find_pred0 s : find pred0 s = size s.
Proof. by []. Qed.
Lemma
find_pred0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
find_predT s : find predT s = 0.
Proof. by case: s. Qed.
Lemma
find_predT
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_find a1 a2 : a1 =1 a2 -> find a1 =1 find a2.
Proof. by move=> Ea; elim=> //= x s IHs; rewrite Ea IHs. Qed.
Lemma
eq_find
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "find" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_filter a1 a2 : a1 =1 a2 -> filter a1 =1 filter a2.
Proof. by move=> Ea; elim=> //= x s IHs; rewrite Ea IHs. Qed.
Lemma
eq_filter
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_count a1 a2 : a1 =1 a2 -> count a1 =1 count a2.
Proof. by move=> Ea s; rewrite -!size_filter (eq_filter Ea). Qed.
Lemma
eq_count
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "count", "eq_filter", "size_filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_has a1 a2 : a1 =1 a2 -> has a1 =1 has a2.
Proof. by move=> Ea s; rewrite !has_count (eq_count Ea). Qed.
Lemma
eq_has
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "eq_count", "has", "has_count" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
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
eq_all
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "all", "all_count", "eq_count" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
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.
Lemma
all_filter
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
s12 : subpred a1 a2.
Hypothesis
s12
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sub_find s : find a2 s <= find a1 s.
Proof. by elim: s => //= x s IHs; case: ifP => // /(contraFF (@s12 x))->. Qed.
Lemma
sub_find
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "find", "s12" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sub_has s : has a1 s -> has a2 s.
Proof. by rewrite !has_find; apply: leq_ltn_trans (sub_find s). Qed.
Lemma
sub_has
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "apply", "has", "has_find", "leq_ltn_trans", "sub_find" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sub_count s : count a1 s <= count a2 s.
Proof. by elim: s => //= x s; apply: leq_add; case a1x: (a1 x); rewrite // s12. Qed.
Lemma
sub_count
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "apply", "count", "leq_add", "s12" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sub_all s : all a1 s -> all a2 s.
Proof. by rewrite !all_count !eqn_leq !count_size => /leq_trans-> //; apply: sub_count. Qed.
Lemma
sub_all
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "all", "all_count", "apply", "count_size", "eqn_leq", "leq_trans", "sub_count" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_pred0 s : filter pred0 s = [::].
Proof. by elim: s. Qed.
Lemma
filter_pred0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_predT s : filter predT s = s.
Proof. by elim: s => //= x s ->. Qed.
Lemma
filter_predT
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_predI a1 a2 s : filter (predI a1 a2) s = filter a1 (filter a2 s).
Proof. by elim: s => //= x s ->; rewrite andbC; case: (a2 x). Qed.
Lemma
filter_predI
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_pred0 s : count pred0 s = 0.
Proof. by rewrite -size_filter filter_pred0. Qed.
Lemma
count_pred0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count", "filter_pred0", "size_filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_predT s : count predT s = size s.
Proof. by rewrite -size_filter filter_predT. Qed.
Lemma
count_predT
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count", "filter_predT", "size", "size_filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_predUI a1 a2 s : count (predU a1 a2) s + count (predI a1 a2) s = count a1 s + count a2 s.
Proof. elim: s => //= x s IHs; rewrite /= addnACA [RHS]addnACA IHs. by case: (a1 x) => //; rewrite addn0. Qed.
Lemma
count_predUI
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "addn0", "addnACA", "count" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_predC a s : count a s + count (predC a) s = size s.
Proof. by elim: s => //= x s IHs; rewrite addnACA IHs; case: (a _). Qed.
Lemma
count_predC
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addnACA", "count", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_filter a1 a2 s : count a1 (filter a2 s) = count (predI a1 a2) s.
Proof. by rewrite -!size_filter filter_predI. Qed.
Lemma
count_filter
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "count", "filter", "filter_predI", "size_filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_pred0 s : has pred0 s = false.
Proof. by rewrite has_count count_pred0. Qed.
Lemma
has_pred0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count_pred0", "has", "has_count" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_predT s : has predT s = (0 < size s).
Proof. by rewrite has_count count_predT. Qed.
Lemma
has_predT
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count_predT", "has", "has_count", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_predC a s : has (predC a) s = ~~ all a s.
Proof. by elim: s => //= x s ->; case (a x). Qed.
Lemma
has_predC
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "has" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_predU a1 a2 s : has (predU a1 a2) s = has a1 s || has a2 s.
Proof. by elim: s => //= x s ->; rewrite -!orbA; do !bool_congr. Qed.
Lemma
has_predU
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "has" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_pred0 s : all pred0 s = (size s == 0).
Proof. by rewrite all_count count_pred0 eq_sym. Qed.
Lemma
all_pred0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all_count", "count_pred0", "eq_sym", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_predT s : all predT s.
Proof. by rewrite all_count count_predT. Qed.
Lemma
all_predT
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all_count", "count_predT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allT (a : pred T) s : (forall x, a x) -> all a s.
Proof. by move/eq_all->; apply/all_predT. Qed.
Lemma
allT
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all_predT", "apply", "eq_all" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_predC a s : all (predC a) s = ~~ has a s.
Proof. by elim: s => //= x s ->; case (a x). Qed.
Lemma
all_predC
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "has" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_predI a1 a2 s : all (predI a1 a2) s = all a1 s && all a2 s.
Proof. apply: (can_inj negbK); rewrite negb_and -!has_predC -has_predU. by apply: eq_has => x; rewrite /= negb_and. Qed.
Lemma
all_predI
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "all", "apply", "eq_has", "has_predC", "has_predU" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop n s {struct s}
:= match s, n with | _ :: s', n'.+1 => drop n' s' | _, _ => s end.
Fixpoint
drop
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "n'" ]
Surgery: drop, take, rot, rotr.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop_behead : drop n0 =1 iter n0 behead.
Proof. by elim: n0 => [|n IHn] [|x s] //; rewrite iterSr -IHn. Qed.
Lemma
drop_behead
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "behead", "drop", "iter", "iterSr" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop0 s : drop 0 s = s.
Proof. by case: s. Qed.
Lemma
drop0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop1 : drop 1 =1 behead.
Proof. by case=> [|x [|y s]]. Qed.
Lemma
drop1
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "behead", "drop" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop_oversize n s : size s <= n -> drop n s = [::].
Proof. by elim: s n => [|x s IHs] []. Qed.
Lemma
drop_oversize
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop_size s : drop (size s) s = [::].
Proof. by rewrite drop_oversize // leqnn. Qed.
Lemma
drop_size
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "drop_oversize", "leqnn", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop_cons x s : drop n0 (x :: s) = if n0 is n.+1 then drop n s else x :: s.
Proof. by []. Qed.
Lemma
drop_cons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_drop s : size (drop n0 s) = size s - n0.
Proof. by elim: s n0 => [|x s IHs] []. Qed.
Lemma
size_drop
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop_cat s1 s2 : drop n0 (s1 ++ s2) = if n0 < size s1 then drop n0 s1 ++ s2 else drop (n0 - size s1) s2.
Proof. by elim: s1 n0 => [|x s1 IHs] []. Qed.
Lemma
drop_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "s1", "s2", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop_size_cat n s1 s2 : size s1 = n -> drop n (s1 ++ s2) = s2.
Proof. by move <-; elim: s1 => //=; rewrite drop0. Qed.
Lemma
drop_size_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "drop0", "s1", "s2", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nconsK n x : cancel (ncons n x) (drop n).
Proof. by elim: n => // -[]. Qed.
Lemma
nconsK
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "ncons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop_drop s n1 n2 : drop n1 (drop n2 s) = drop (n1 + n2) s.
Proof. by elim: s n2 => // x s ihs [|n2]; rewrite ?drop0 ?addn0 ?addnS /=. Qed.
Lemma
drop_drop
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn0", "addnS", "drop", "drop0" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take n s {struct s}
:= match s, n with | x :: s', n'.+1 => x :: take n' s' | _, _ => [::] end.
Fixpoint
take
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "n'" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take0 s : take 0 s = [::].
Proof. by case: s. Qed.
Lemma
take0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take_oversize n s : size s <= n -> take n s = s.
Proof. by elim: s n => [|x s IHs] [|n] //= /IHs->. Qed.
Lemma
take_oversize
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "size", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take_size s : take (size s) s = s.
Proof. exact: take_oversize. Qed.
Lemma
take_size
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "size", "take", "take_oversize" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take_cons x s : take n0 (x :: s) = if n0 is n.+1 then x :: (take n s) else [::].
Proof. by []. Qed.
Lemma
take_cons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop_rcons s : n0 <= size s -> forall x, drop n0 (rcons s x) = rcons (drop n0 s) x.
Proof. by elim: s n0 => [|y s IHs] []. Qed.
Lemma
drop_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "rcons", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cat_take_drop s : take n0 s ++ drop n0 s = s.
Proof. by elim: s n0 => [|x s IHs] [|n] //=; rewrite IHs. Qed.
Lemma
cat_take_drop
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_takel s : n0 <= size s -> size (take n0 s) = n0.
Proof. by move/subKn; rewrite -size_drop -[in size s](cat_take_drop s) size_cat addnK. Qed.
Lemma
size_takel
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addnK", "cat_take_drop", "size", "size_cat", "size_drop", "subKn", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_take s : size (take n0 s) = if n0 < size s then n0 else size s.
Proof. have [le_sn | lt_ns] := leqP (size s) n0; first by rewrite take_oversize. by rewrite size_takel // ltnW. Qed.
Lemma
size_take
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "leqP", "ltnW", "size", "size_takel", "take", "take_oversize" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_take_min s : size (take n0 s) = minn n0 (size s).
Proof. exact: size_take. Qed.
Lemma
size_take_min
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "minn", "size", "size_take", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take_cat s1 s2 : take n0 (s1 ++ s2) = if n0 < size s1 then take n0 s1 else s1 ++ take (n0 - size s1) s2.
Proof. elim: s1 n0 => [|x s1 IHs] [|n] //=. by rewrite ltnS subSS -(fun_if (cons x)) -IHs. Qed.
Lemma
take_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "ltnS", "s1", "s2", "size", "subSS", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take_size_cat n s1 s2 : size s1 = n -> take n (s1 ++ s2) = s1.
Proof. by move <-; elim: s1 => [|x s1 IHs]; rewrite ?take0 //= IHs. Qed.
Lemma
take_size_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "s1", "s2", "size", "take", "take0" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
takel_cat s1 s2 : n0 <= size s1 -> take n0 (s1 ++ s2) = take n0 s1.
Proof. by rewrite take_cat; case: ltngtP => // ->; rewrite subnn take0 take_size cats0. Qed.
Lemma
takel_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cats0", "ltngtP", "s1", "s2", "size", "subnn", "take", "take0", "take_cat", "take_size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_drop s i : nth (drop n0 s) i = nth s (n0 + i).
Proof. rewrite -[s in RHS]cat_take_drop nth_cat size_take ltnNge. case: ltnP => [?|le_s_n0]; rewrite ?(leq_trans le_s_n0) ?leq_addr ?addKn //=. by rewrite drop_oversize // !nth_default. Qed.
Lemma
nth_drop
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addKn", "cat_take_drop", "drop", "drop_oversize", "leq_addr", "leq_trans", "ltnNge", "ltnP", "nth", "nth_cat", "nth_default", "size_take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
find_ltn p s i : has p (take i s) -> find p s < i.
Proof. by elim: s i => [|y s ihs] [|i]//=; case: (p _) => //= /ihs. Qed.
Lemma
find_ltn
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "has", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_take p s i : has p s -> has p (take i s) = (find p s < i).
Proof. by elim: s i => [|y s ihs] [|i]//=; case: (p _) => //= /ihs ->. Qed.
Lemma
has_take
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "has", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_take_leq (p : pred T) (s : seq T) i : i <= size s -> has p (take i s) = (find p s < i).
Proof. by elim: s i => [|y s ihs] [|i]//=; case: (p _) => //= /ihs ->. Qed.
Lemma
has_take_leq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "has", "seq", "size", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_take i : i < n0 -> forall s, nth (take n0 s) i = nth s i.
Proof. move=> lt_i_n0 s; case lt_n0_s: (n0 < size s). by rewrite -[s in RHS]cat_take_drop nth_cat size_take lt_n0_s /= lt_i_n0. by rewrite -[s in LHS]cats0 take_cat lt_n0_s /= cats0. Qed.
Lemma
nth_take
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat_take_drop", "cats0", "nth", "nth_cat", "size", "size_take", "take", "take_cat" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take_min i j s : take (minn i j) s = take i (take j s).
Proof. by elim: s i j => //= a l IH [|i] [|j] //=; rewrite minnSS IH. Qed.
Lemma
take_min
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "minn", "minnSS", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take_takel i j s : i <= j -> take i (take j s) = take i s.
Proof. by move=> ?; rewrite -take_min (minn_idPl _). Qed.
Lemma
take_takel
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "minn_idPl", "take", "take_min" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d