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
aP : forall x, reflect (A x) (a x).
Hypothesis
aP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
hasPP : reflect (exists2 x, x \in s & A x) (has a s).
Proof. by apply: (iffP hasP) => -[x ? /aP]; exists x. Qed.
Lemma
hasPP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "aP", "apply", "has", "hasP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allPP : reflect {in s, forall x, A x} (all a s).
Proof. by apply: (iffP allP) => a_s x /a_s/aP. Qed.
Lemma
allPP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "aP", "all", "allP", "apply" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_in_filter s : {in s, a1 =1 a2} -> filter a1 s = filter a2 s.
Proof. by elim: s => //= x s IHs /forall_cons [-> /IHs ->]. Qed.
Lemma
eq_in_filter
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "filter", "forall_cons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_in_find s : {in s, a1 =1 a2} -> find a1 s = find a2 s.
Proof. by elim: s => //= x s IHs /forall_cons [-> /IHs ->]. Qed.
Lemma
eq_in_find
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "find", "forall_cons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_in_count s : {in s, a1 =1 a2} -> count a1 s = count a2 s.
Proof. by move/eq_in_filter=> eq_a12; rewrite -!size_filter eq_a12. Qed.
Lemma
eq_in_count
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "count", "eq_in_filter", "size_filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_in_all s : {in s, a1 =1 a2} -> all a1 s = all a2 s.
Proof. by move=> eq_a12; rewrite !all_count eq_in_count. Qed.
Lemma
eq_in_all
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "all", "all_count", "eq_in_count" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_in_has s : {in s, a1 =1 a2} -> has a1 s = has a2 s.
Proof. by move/eq_in_filter=> eq_a12; rewrite !has_filter eq_a12. Qed.
Lemma
eq_in_has
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "a1", "a2", "eq_in_filter", "has", "has_filter" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_has_r s1 s2 : s1 =i s2 -> has^~ s1 =1 has^~ s2.
Proof. by move=> Es a; apply/hasP/hasP=> -[x sx ax]; exists x; rewrite ?Es in sx *. Qed.
Lemma
eq_has_r
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "has", "hasP", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_all_r s1 s2 : s1 =i s2 -> all^~ s1 =1 all^~ s2.
Proof. by move=> Es a; apply/negb_inj; rewrite -!has_predC (eq_has_r Es). Qed.
Lemma
eq_all_r
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "apply", "eq_has_r", "has_predC", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_sym s1 s2 : has [in s1] s2 = has [in s2] s1.
Proof. by apply/hasP/hasP=> -[x]; exists x. Qed.
Lemma
has_sym
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "has", "hasP", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_pred1 x s : has (pred1 x) s = (x \in s).
Proof. by rewrite -(eq_has (mem_seq1^~ x)) (has_sym [:: x]) /= orbF. Qed.
Lemma
has_pred1
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eq_has", "has", "has_sym", "mem_seq1", "pred1" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
mem_rev s : rev s =i s.
Proof. by move=> a; rewrite -!has_pred1 has_rev. Qed.
Lemma
mem_rev
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "has_pred1", "has_rev", "rev" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
constant s
:= if s is x :: s' then all (pred1 x) s' else true.
Definition
constant
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "pred1" ]
Constant sequences, i.e., the image of nseq.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_pred1P x s : reflect (s = nseq (size s) x) (all (pred1 x) s).
Proof. elim: s => [|y s IHs] /=; first by left. case: eqP => [->{y} | ne_xy]; last by right=> [] [? _]; case ne_xy. by apply: (iffP IHs) => [<- //| []]. Qed.
Lemma
all_pred1P
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "apply", "last", "nseq", "pred1", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_pred1_constant x s : all (pred1 x) s -> constant s.
Proof. by case: s => //= y s /andP[/eqP->]. Qed.
Lemma
all_pred1_constant
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "constant", "pred1" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_pred1_nseq x n : all (pred1 x) (nseq n x).
Proof. by rewrite all_nseq /= eqxx orbT. Qed.
Lemma
all_pred1_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all_nseq", "eqxx", "nseq", "pred1" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
mem_nseq n x y : (y \in nseq n x) = (0 < n) && (y == x).
Proof. by rewrite -has_pred1 has_nseq eq_sym. Qed.
Lemma
mem_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eq_sym", "has_nseq", "has_pred1", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nseqP n x y : reflect (y = x /\ n > 0) (y \in nseq n x).
Proof. by rewrite mem_nseq andbC; apply: (iffP andP) => -[/eqP]. Qed.
Lemma
nseqP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "mem_nseq", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
constant_nseq n x : constant (nseq n x).
Proof. exact: all_pred1_constant (all_pred1_nseq x n). Qed.
Lemma
constant_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_pred1_constant", "all_pred1_nseq", "constant", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
constantP s : reflect (exists x, s = nseq (size s) x) (constant s).
Proof. apply: (iffP idP) => [| [x ->]]; last exact: constant_nseq. case: s => [|x s] /=; first by exists x0. by move/all_pred1P=> def_s; exists x; rewrite -def_s. Qed.
Lemma
constantP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_pred1P", "apply", "constant", "constant_nseq", "last", "nseq", "size" ]
Uses x0
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniq s
:= if s is x :: s' then (x \notin s') && uniq s' else true.
Fixpoint
uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
Duplicate-freenes.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cons_uniq x s : uniq (x :: s) = (x \notin s) && uniq s.
Proof. by []. Qed.
Lemma
cons_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cat_uniq s1 s2 : uniq (s1 ++ s2) = [&& uniq s1, ~~ has [in s1] s2 & uniq s2].
Proof. elim: s1 => [|x s1 IHs]; first by rewrite /= has_pred0. by rewrite has_sym /= mem_cat !negb_or has_sym IHs -!andbA; do !bool_congr. Qed.
Lemma
cat_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "has", "has_pred0", "has_sym", "mem_cat", "s1", "s2", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniq_catC s1 s2 : uniq (s1 ++ s2) = uniq (s2 ++ s1).
Proof. by rewrite !cat_uniq has_sym andbCA andbA andbC. Qed.
Lemma
uniq_catC
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat_uniq", "has_sym", "s1", "s2", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniq_catCA s1 s2 s3 : uniq (s1 ++ s2 ++ s3) = uniq (s2 ++ s1 ++ s3).
Proof. by rewrite !catA -!(uniq_catC s3) !(cat_uniq s3) uniq_catC !has_cat orbC. Qed.
Lemma
uniq_catCA
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "catA", "cat_uniq", "has_cat", "s1", "s2", "s3", "uniq", "uniq_catC" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniq_cat_inLR x s1 s2 : uniq (s1 ++ s2) -> x \in s1 ++ s2 -> (x \in s1) = (x \notin s2).
Proof. rewrite mem_cat=> s_uniq /orP[] x_in; move: s_uniq. by rewrite uniq_catC cat_uniq => /and3P[_ /hasPn /(_ _ x_in)->]. by rewrite cat_uniq => /and3P[_ /hasPn /(_ _ x_in) /= /negPf->]; rewrite x_in. Qed.
Lemma
uniq_cat_inLR
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat_uniq", "hasPn", "mem_cat", "s1", "s2", "uniq", "uniq_catC" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniq_cat_inRL x s1 s2 : uniq (s1 ++ s2) -> x \in s1 ++ s2 -> (x \in s2) = (x \notin s1).
Proof. by rewrite mem_catC uniq_catC; apply: uniq_cat_inLR. Qed.
Lemma
uniq_cat_inRL
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "mem_catC", "s1", "s2", "uniq", "uniq_catC", "uniq_cat_inLR" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rcons_uniq s x : uniq (rcons s x) = (x \notin s) && uniq s.
Proof. by rewrite -cats1 uniq_catC. Qed.
Lemma
rcons_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cats1", "rcons", "uniq", "uniq_catC" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_uniq s a : uniq s -> uniq (filter a s).
Proof. elim: s => //= x s IHs /andP[s'x]; case: ifP => //= a_x /IHs->. by rewrite mem_filter a_x s'x. Qed.
Lemma
filter_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "filter", "mem_filter", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rot_uniq s : uniq (rot n0 s) = uniq s.
Proof. by rewrite /rot uniq_catC cat_take_drop. Qed.
Lemma
rot_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat_take_drop", "rot", "uniq", "uniq_catC" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rev_uniq s : uniq (rev s) = uniq s.
Proof. elim: s => // x s IHs. by rewrite rev_cons -cats1 cat_uniq /= andbT andbC mem_rev orbF IHs. Qed.
Lemma
rev_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat_uniq", "cats1", "mem_rev", "rev", "rev_cons", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_memPn x s : reflect (count_mem x s = 0) (x \notin s).
Proof. by rewrite -has_pred1 has_count -eqn0Ngt; apply: eqP. Qed.
Lemma
count_memPn
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "count_mem", "eqn0Ngt", "has_count", "has_pred1" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_uniq_mem s x : uniq s -> count_mem x s = (x \in s).
Proof. elim: s => //= y s IHs /andP[/negbTE s'y /IHs-> {IHs}]. by rewrite in_cons; case: (eqVneq y x) => // <-; rewrite s'y. Qed.
Lemma
count_uniq_mem
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count_mem", "eqVneq", "in_cons", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
leq_uniq_countP x s1 s2 : uniq s1 -> reflect (x \in s1 -> x \in s2) (count_mem x s1 <= count_mem x s2).
Proof. move/count_uniq_mem->; case: (boolP (_ \in _)) => //= _; last by constructor. by rewrite -has_pred1 has_count; apply: (iffP idP) => //; apply. Qed.
Lemma
leq_uniq_countP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "count_mem", "count_uniq_mem", "has_count", "has_pred1", "last", "s1", "s2", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
leq_uniq_count s1 s2 : uniq s1 -> {subset s1 <= s2} -> (forall x, count_mem x s1 <= count_mem x s2).
Proof. by move=> s1_uniq s1_s2 x; apply/leq_uniq_countP/s1_s2. Qed.
Lemma
leq_uniq_count
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "count_mem", "leq_uniq_countP", "s1", "s2", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_pred1_uniq s x : uniq s -> x \in s -> filter (pred1 x) s = [:: x].
Proof. move=> uniq_s s_x; rewrite (all_pred1P _ _ (filter_all _ _)). by rewrite size_filter count_uniq_mem ?s_x. Qed.
Lemma
filter_pred1_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_pred1P", "count_uniq_mem", "filter", "filter_all", "pred1", "size_filter", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
undup s
:= if s is x :: s' then if x \in s' then undup s' else x :: undup s' else [::].
Fixpoint
undup
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
Removing duplicates
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_undup s : size (undup s) <= size s.
Proof. by elim: s => //= x s IHs; case: (x \in s) => //=; apply: ltnW. Qed.
Lemma
size_undup
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "ltnW", "size", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
mem_undup s : undup s =i s.
Proof. move=> x; elim: s => //= y s IHs. by case s_y: (y \in s); rewrite !inE IHs //; case: eqP => [->|]. Qed.
Lemma
mem_undup
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "inE", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
undup_uniq s : uniq (undup s).
Proof. by elim: s => //= x s IHs; case s_x: (x \in s); rewrite //= mem_undup s_x. Qed.
Lemma
undup_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "mem_undup", "undup", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
undup_id s : uniq s -> undup s = s.
Proof. by elim: s => //= x s IHs /andP[/negbTE-> /IHs->]. Qed.
Lemma
undup_id
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "undup", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
ltn_size_undup s : (size (undup s) < size s) = ~~ uniq s.
Proof. by elim: s => //= x s IHs; case s_x: (x \in s); rewrite //= ltnS size_undup. Qed.
Lemma
ltn_size_undup
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "ltnS", "size", "size_undup", "undup", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
filter_undup p s : filter p (undup s) = undup (filter p s).
Proof. elim: s => //= x s IHs; rewrite (fun_if undup) [_ = _]fun_if /= mem_filter /=. by rewrite (fun_if (filter p)) /= IHs; case: ifP => -> //=; apply: if_same. Qed.
Lemma
filter_undup
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "filter", "mem_filter", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
undup_nil s : undup s = [::] -> s = [::].
Proof. by case: s => //= x s; rewrite -mem_undup; case: ifP; case: undup. Qed.
Lemma
undup_nil
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "mem_undup", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
undup_cat s t : undup (s ++ t) = [seq x <- undup s | x \notin t] ++ undup t.
Proof. by elim: s => //= x s ->; rewrite mem_cat; do 2 case: in_mem => //=. Qed.
Lemma
undup_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "mem_cat", "seq", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
undup_rcons s x : undup (rcons s x) = rcons [seq y <- undup s | y != x] x.
Proof. by rewrite -!cats1 undup_cat; congr cat; apply: eq_filter => y; rewrite inE. Qed.
Lemma
undup_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "cat", "cats1", "eq_filter", "inE", "rcons", "seq", "undup", "undup_cat" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_undup s p : count p (undup s) <= count p s.
Proof. by rewrite -!size_filter filter_undup size_undup. Qed.
Lemma
count_undup
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count", "filter_undup", "size_filter", "size_undup", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_undup p s : has p (undup s) = has p s.
Proof. by apply: eq_has_r => x; rewrite mem_undup. Qed.
Lemma
has_undup
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "eq_has_r", "has", "mem_undup", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_undup p s : all p (undup s) = all p s.
Proof. by apply: eq_all_r => x; rewrite mem_undup. Qed.
Lemma
all_undup
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "apply", "eq_all_r", "mem_undup", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index x
:= find (pred1 x).
Definition
index
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find", "pred1" ]
Lookup
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_size x s : index x s <= size s.
Proof. by rewrite /index find_size. Qed.
Lemma
index_size
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find_size", "index", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_mem x s : (index x s < size s) = (x \in s).
Proof. by rewrite -has_pred1 has_find. Qed.
Lemma
index_mem
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "has_find", "has_pred1", "index", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
memNindex x s : x \notin s -> index x s = size s.
Proof. by rewrite -has_pred1 => /hasNfind. Qed.
Lemma
memNindex
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "hasNfind", "has_pred1", "index", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_index x s : x \in s -> nth s (index x s) = x.
Proof. by rewrite -has_pred1 => /(nth_find x0)/eqP. Qed.
Lemma
nth_index
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "has_pred1", "index", "nth", "nth_find" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_inj s : {in s &, injective (index ^~ s)}.
Proof. by move=> x y x_s y_s eidx; rewrite -(nth_index x_s) eidx nth_index. Qed.
Lemma
index_inj
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "index", "nth_index" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_cat x s1 s2 : index x (s1 ++ s2) = if x \in s1 then index x s1 else size s1 + index x s2.
Proof. by rewrite /index find_cat has_pred1. Qed.
Lemma
index_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "find_cat", "has_pred1", "index", "s1", "s2", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_ltn x s i : x \in take i s -> index x s < i.
Proof. by rewrite -has_pred1; apply: find_ltn. Qed.
Lemma
index_ltn
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "find_ltn", "has_pred1", "index", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
in_take x s i : x \in s -> (x \in take i s) = (index x s < i).
Proof. by rewrite -?has_pred1; apply: has_take. Qed.
Lemma
in_take
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "has_pred1", "has_take", "index", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
in_take_leq x s i : i <= size s -> (x \in take i s) = (index x s < i).
Proof. by rewrite -?has_pred1; apply: has_take_leq. Qed.
Lemma
in_take_leq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "has_pred1", "has_take_leq", "index", "size", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_nth i s : i < size s -> index (nth s i) s <= i.
Proof. move=> lti; rewrite -ltnS index_ltn// -(@nth_take i.+1)// mem_nth // size_take. by case: ifP. Qed.
Lemma
index_nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "index", "index_ltn", "ltnS", "mem_nth", "nth", "nth_take", "size", "size_take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nthK s: uniq s -> {in gtn (size s), cancel (nth s) (index^~ s)}.
Proof. elim: s => //= x s IHs /andP[s'x Us] i; rewrite inE ltnS eq_sym -if_neg. by case: i => /= [_|i lt_i_s]; rewrite ?eqxx ?IHs ?(memPn s'x) ?mem_nth. Qed.
Lemma
nthK
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eq_sym", "eqxx", "gtn", "inE", "index", "ltnS", "memPn", "mem_nth", "nth", "size", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_uniq i s : i < size s -> uniq s -> index (nth s i) s = i.
Proof. by move/nthK. Qed.
Lemma
index_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "index", "nth", "nthK", "size", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_head x s : index x (x :: s) = 0.
Proof. by rewrite /= eqxx. Qed.
Lemma
index_head
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eqxx", "index" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_last x s : uniq (x :: s) -> index (last x s) (x :: s) = size s.
Proof. rewrite lastI rcons_uniq -cats1 index_cat size_belast. by case: ifP => //=; rewrite eqxx addn0. Qed.
Lemma
index_last
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn0", "cats1", "eqxx", "index", "index_cat", "last", "lastI", "rcons_uniq", "size", "size_belast", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_uniq s i j : i < size s -> j < size s -> uniq s -> (nth s i == nth s j) = (i == j).
Proof. by move=> lti ltj /nthK/can_in_eq->. Qed.
Lemma
nth_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "can_in_eq", "nth", "nthK", "size", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniqPn s : reflect (exists i j, [/\ i < j, j < size s & nth s i = nth s j]) (~~ uniq s).
Proof. apply: (iffP idP) => [|[i [j [ltij ltjs]]]]; last first. by apply: contra_eqN => Us; rewrite nth_uniq ?ltn_eqF // (ltn_trans ltij). elim: s => // x s IHs /nandP[/negbNE | /IHs[i [j]]]; last by exists i.+1, j.+1. by exists 0, (index x s).+1; rewrite !ltnS index_mem /= nth_index. Qed.
Lemma
uniqPn
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "contra_eqN", "index", "index_mem", "last", "ltnS", "ltn_eqF", "ltn_trans", "nth", "nth_index", "nth_uniq", "size", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniqP s : reflect {in gtn (size s) &, injective (nth s)} (uniq s).
Proof. apply: (iffP idP) => [/nthK/can_in_inj// | nth_inj]. apply/uniqPn => -[i [j [ltij ltjs /nth_inj/eqP/idPn]]]. by rewrite !inE (ltn_trans ltij ltjs) ltn_eqF //=; case. Qed.
Lemma
uniqP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "gtn", "inE", "ltn_eqF", "ltn_trans", "nth", "nthK", "size", "uniq", "uniqPn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
mem_rot s : rot n0 s =i s.
Proof. by move=> x; rewrite -[s in RHS](cat_take_drop n0) !mem_cat /= orbC. Qed.
Lemma
mem_rot
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat_take_drop", "mem_cat", "rot" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eqseq_rot s1 s2 : (rot n0 s1 == rot n0 s2) = (s1 == s2).
Proof. exact/inj_eq/rot_inj. Qed.
Lemma
eqseq_rot
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "inj_eq", "rot", "rot_inj", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
drop_index s (n := index x0 s) : x0 \in s -> drop n s = x0 :: drop n.+1 s.
Proof. by move=> xs; rewrite (drop_nth x0) ?index_mem ?nth_index. Qed.
Lemma
drop_index
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "drop_nth", "index", "index_mem", "nth_index" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
index_pivot x s1 s2 (s := s1 ++ x :: s2) : x \notin s1 -> index x s = size s1.
Proof. by rewrite index_cat/= eqxx addn0; case: ifPn. Qed.
Lemma
index_pivot
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn0", "eqxx", "index", "index_cat", "s1", "s2", "size" ]
lemmas about the pivot pattern [_ ++ _ :: _]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
take_pivot x s2 s1 (s := s1 ++ x :: s2) : x \notin s1 -> take (index x s) s = s1.
Proof. by move=> /index_pivot->; rewrite take_size_cat. Qed.
Lemma
take_pivot
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "index", "index_pivot", "s1", "s2", "take", "take_size_cat" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rev_pivot x s1 s2 : rev (s1 ++ x :: s2) = rev s2 ++ x :: rev s1.
Proof. by rewrite rev_cat rev_cons cat_rcons. Qed.
Lemma
rev_pivot
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat_rcons", "rev", "rev_cat", "rev_cons", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eqseq_pivot2l x s1 s2 s3 s4 : x \notin s1 -> x \notin s3 -> (s1 ++ x :: s2 == s3 ++ x :: s4) = (s1 == s3) && (s2 == s4).
Proof. move=> xNs1 xNs3; apply/idP/idP => [E|/andP[/eqP-> /eqP->]//]. suff S : size s1 = size s3 by rewrite eqseq_cat// eqseq_cons eqxx in E. by rewrite -(index_pivot s2 xNs1) (eqP E) index_pivot. Qed.
Lemma
eqseq_pivot2l
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "eqseq_cat", "eqseq_cons", "eqxx", "index_pivot", "s1", "s2", "s3", "s4", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eqseq_pivot2r x s1 s2 s3 s4 : x \notin s2 -> x \notin s4 -> (s1 ++ x :: s2 == s3 ++ x :: s4) = (s1 == s3) && (s2 == s4).
Proof. move=> xNs2 xNs4; rewrite -(can_eq revK) !rev_pivot. by rewrite eqseq_pivot2l ?mem_rev // !(can_eq revK) andbC. Qed.
Lemma
eqseq_pivot2r
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "can_eq", "eqseq_pivot2l", "mem_rev", "revK", "rev_pivot", "s1", "s2", "s3", "s4" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eqseq_pivotl x s1 s2 s3 s4 : x \notin s1 -> x \notin s2 -> (s1 ++ x :: s2 == s3 ++ x :: s4) = (s1 == s3) && (s2 == s4).
Proof. move=> xNs1 xNs2; apply/idP/idP => [E|/andP[/eqP-> /eqP->]//]. rewrite -(@eqseq_pivot2l x)//; have /eqP/(congr1 (count_mem x)) := E. rewrite !count_cat/= eqxx !addnS (count_memPn _ _ xNs1) (count_memPn _ _ xNs2). by move=> -[/esym/eqP]; rewrite addn_eq0 => /andP[/eqP/count_memPn]. Qed.
Lemma
eqseq_pivotl
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addnS", "addn_eq0", "apply", "count_cat", "count_mem", "count_memPn", "eqseq_pivot2l", "eqxx", "s1", "s2", "s3", "s4" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eqseq_pivotr x s1 s2 s3 s4 : x \notin s3 -> x \notin s4 -> (s1 ++ x :: s2 == s3 ++ x :: s4) = (s1 == s3) && (s2 == s4).
Proof. by move=> *; rewrite eq_sym eqseq_pivotl//; case: eqVneq => /=. Qed.
Lemma
eqseq_pivotr
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eqVneq", "eq_sym", "eqseq_pivotl", "s1", "s2", "s3", "s4" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniq_eqseq_pivotl x s1 s2 s3 s4 : uniq (s1 ++ x :: s2) -> (s1 ++ x :: s2 == s3 ++ x :: s4) = (s1 == s3) && (s2 == s4).
Proof. by rewrite uniq_catC/= mem_cat => /andP[/norP[? ?] _]; rewrite eqseq_pivotl. Qed.
Lemma
uniq_eqseq_pivotl
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eqseq_pivotl", "mem_cat", "s1", "s2", "s3", "s4", "uniq", "uniq_catC" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniq_eqseq_pivotr x s1 s2 s3 s4 : uniq (s3 ++ x :: s4) -> (s1 ++ x :: s2 == s3 ++ x :: s4) = (s1 == s3) && (s2 == s4).
Proof. by move=> ?; rewrite eq_sym uniq_eqseq_pivotl//; case: eqVneq => /=. Qed.
Lemma
uniq_eqseq_pivotr
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eqVneq", "eq_sym", "s1", "s2", "s3", "s4", "uniq", "uniq_eqseq_pivotl" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
"'has_ view"
:= (hasPP _ (fun _ => view)) (at level 4, right associativity, format "''has_' view").
Notation
'has_ view
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "hasPP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
"'all_ view"
:= (allPP _ (fun _ => view)) (at level 4, right associativity, format "''all_' view").
Notation
'all_ view
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allPP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rot_index s x (i := index x s) : x \in s -> rot i s = x :: (drop i.+1 s ++ take i s).
Proof. by move=> x_s; rewrite /rot drop_index. Qed.
Lemma
rot_index
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "drop_index", "index", "rot", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rot_to_spec s x
:= RotToSpec i s' of rot i s = x :: s'.
Variant
rot_to_spec
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "rot" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rot_to s x : x \in s -> rot_to_spec s x.
Proof. by move=> /rot_index /RotToSpec. Qed.
Lemma
rot_to
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "rot_index", "rot_to_spec" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nthP (T : eqType) (s : seq T) x x0 : reflect (exists2 i, i < size s & nth x0 s i = x) (x \in s).
Proof. apply: (iffP idP) => [|[n Hn <-]]; last exact: mem_nth. by exists (index x s); [rewrite index_mem | apply nth_index]. Qed.
Lemma
nthP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "index", "index_mem", "last", "mem_nth", "nth", "nth_index", "seq", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
has_nthP a s x0 : reflect (exists2 i, i < size s & a (nth x0 s i)) (has a s).
Proof. elim: s => [|x s IHs] /=; first by right; case. case nax: (a x); first by left; exists 0. by apply: (iffP IHs) => [[i]|[[|i]]]; [exists i.+1 | rewrite nax | exists i]. Qed.
Lemma
has_nthP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "has", "nth", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all_nthP a s x0 : reflect (forall i, i < size s -> a (nth x0 s i)) (all a s).
Proof. rewrite -(eq_all (fun x => negbK (a x))) all_predC. case: (has_nthP _ _ x0) => [na_s | a_s]; [right=> a_s | left=> i lti]. by case: na_s => i lti; rewrite a_s. by apply/idPn=> na_si; case: a_s; exists i. Qed.
Lemma
all_nthP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all_predC", "apply", "eq_all", "has_nthP", "nth", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
set_nthE s x0 n x : set_nth x0 s n x = if n < size s then take n s ++ x :: drop n.+1 s else s ++ ncons (n - size s) x0 [:: x].
Proof. elim: s n => [|a s IH] n /=; first by rewrite subn0 set_nth_nil. case: n => [|n]; first by rewrite drop0. by rewrite ltnS /=; case: ltnP (IH n) => _ ->. Qed.
Lemma
set_nthE
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "drop", "drop0", "ltnP", "ltnS", "ncons", "set_nth", "set_nth_nil", "size", "subn0", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_set_nth a s x0 n x : count a (set_nth x0 s n x) = count a s + a x - a (nth x0 s n) * (n < size s) + (a x0) * (n - size s).
Proof. rewrite set_nthE; case: ltnP => [nlts|nges]; last first. rewrite -cat_nseq !count_cat count_nseq /=. by rewrite muln0 addn0 subn0 addnAC addnA. have -> : n - size s = 0 by apply/eqP; rewrite subn_eq0 ltnW. rewrite -[in count a s](cat_take_drop n s) [drop n s](drop_nth x0)//. by rewrite !count_cat/= muln1 mul...
Lemma
count_set_nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn0", "addnA", "addnAC", "addnK", "apply", "cat_nseq", "cat_take_drop", "count", "count_cat", "count_nseq", "drop", "drop_nth", "last", "ltnP", "ltnW", "muln0", "muln1", "nth", "set_nth", "set_nthE", "size", "subn0", "subn_eq0" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_set_nth_ltn a s x0 n x : n < size s -> count a (set_nth x0 s n x) = count a s + a x - a (nth x0 s n).
Proof. move=> nlts; rewrite count_set_nth nlts muln1. have -> : n - size s = 0 by apply/eqP; rewrite subn_eq0 ltnW. by rewrite muln0 addn0. Qed.
Lemma
count_set_nth_ltn
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn0", "apply", "count", "count_set_nth", "ltnW", "muln0", "muln1", "nth", "set_nth", "size", "subn_eq0" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
count_set_nthF a s x0 n x : ~~ a x0 -> count a (set_nth x0 s n x) = count a s + a x - a (nth x0 s n).
Proof. move=> /negbTE ax0; rewrite count_set_nth ax0 mul0n addn0. case: ltnP => [_|nges]; first by rewrite muln1. by rewrite nth_default// ax0 subn0. Qed.
Lemma
count_set_nthF
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn0", "count", "count_set_nth", "ltnP", "mul0n", "muln1", "nth", "nth_default", "set_nth", "subn0" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
set_nth_default n : n < size s -> nth x0 s n = nth y0 s n.
Proof. by elim: s n => [|y s' IHs] [|n] //= /IHs. Qed.
Lemma
set_nth_default
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nth", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
set_last_default : size s > 0 -> last x0 s = last y0 s.
Proof. by elim: s => [|y s' IHs] //= /IHs. Qed.
Lemma
set_last_default
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "last", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
headI T s (x : T) : rcons s x = head x s :: behead (rcons s x).
Proof. by case: s. Qed.
Lemma
headI
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "behead", "head", "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
last_take x n s : last x (take n s) = if n > 0 then if n <= size s then nth x s n.-1 else last x s else x.
Proof. elim: n s => [|n ihn] [|y s] //= in x *; rewrite {}ihn ltnS; case: n => //=. by move=> n; case: ltnP => // n_lt; apply/set_nth_default. Qed.
Lemma
last_take
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "last", "ltnP", "ltnS", "nth", "set_nth_default", "size", "take" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
last_drop x n s : last x (drop n s) = if n < size s then last x s else x.
Proof. case: ltnP => sn; last by rewrite drop_oversize. rewrite -[s in RHS](cat_take_drop n) last_cat. by rewrite (@set_last_default _ _ x) ?size_drop ?subn_gt0. Qed.
Lemma
last_drop
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat_take_drop", "drop", "drop_oversize", "last", "last_cat", "ltnP", "set_last_default", "size", "size_drop", "subn_gt0" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bitseq
:= seq bool.
Definition
bitseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bitseq_predType
:= Eval hnf in [predType of bitseq].
Canonical
bitseq_predType
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "bitseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
split_find_nth_spec p : seq T -> seq T -> seq T -> T -> Type
:= FindNth x s1 s2 of p x & ~~ has p s1 : split_find_nth_spec p (rcons s1 x ++ s2) s1 s2 x.
Variant
split_find_nth_spec
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "has", "rcons", "s1", "s2", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d