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
all_allpairsP (S : eqType) (T : S -> eqType) (R : Type) (p : pred R) (f : forall x : S, T x -> R) (s : seq S) (t : forall x : S, seq (T x)) : reflect (forall (x : S) (y : T x), x \in s -> y \in t x -> p (f x y)) (all p [seq f x y | x <- s, y <- t x]).
Proof. elim: s => [|x s IHs]; first by constructor. rewrite /= all_cat all_map /preim. apply/(iffP andP)=> [[/allP /= ? ? x' y x'_in_xs]|p_xs_t]. by move: x'_in_xs y => /[1!inE] /predU1P [-> //|? ?]; exact: IHs. split; first by apply/allP => ?; exact/p_xs_t/mem_head. by apply/IHs => x' y x'_in_s; apply: p_xs_t; rewri...
Lemma
all_allpairsP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "allP", "all_cat", "all_map", "apply", "inE", "mem_head", "predU1P", "seq", "split" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allpairsP f s t (z : R) : reflect (exists p, [/\ p.1 \in s, p.2 \in t & z = f p.1 p.2]) (z \in [seq f x y | x <- s, y <- t]).
Proof. by apply: (iffP allpairsPdep) => [[x[y]]|[[x y]]]; [exists (x, y)|exists x, y]. Qed.
Lemma
allpairsP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allpairsPdep", "apply", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allpairs_f f s t x y : x \in s -> y \in t -> f x y \in [seq f x y | x <- s, y <- t].
Proof. exact: allpairs_f_dep. Qed.
Lemma
allpairs_f
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allpairs_f_dep", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_in_allpairs f1 f2 s t : {in s & t, f1 =2 f2} <-> [seq f1 x y : R | x <- s, y <- t] = [seq f2 x y | x <- s, y <- t].
Proof. split=> [eq_f | /eq_in_allpairs_dep-eq_f x y /eq_f/(_ y)//]. by apply/eq_in_allpairs_dep=> x /eq_f. Qed.
Lemma
eq_in_allpairs
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "eq_f", "eq_in_allpairs_dep", "f1", "f2", "seq", "split" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
perm_allpairs f s1 t1 s2 t2 : perm_eq s1 s2 -> perm_eq t1 t2 -> perm_eq [seq f x y | x <- s1, y <- t1] [seq f x y | x <- s2, y <- t2].
Proof. by move=> perm_s perm_t; apply: perm_allpairs_dep. Qed.
Lemma
perm_allpairs
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "perm_allpairs_dep", "perm_eq", "s1", "s2", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
mem_allpairs f s1 t1 s2 t2 : s1 =i s2 -> t1 =i t2 -> [seq f x y | x <- s1, y <- t1] =i [seq f x y | x <- s2, y <- t2].
Proof. by move=> eq_s eq_t; apply: mem_allpairs_dep. Qed.
Lemma
mem_allpairs
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "mem_allpairs_dep", "s1", "s2", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allpairs_uniq f s t (st := [seq (x, y) | x <- s, y <- t]) : uniq s -> uniq t -> {in st &, injective (uncurry f)} -> uniq [seq f x y | x <- s, y <- t].
Proof. move=> Us Ut inj_f; rewrite -(map_allpairs (uncurry f) (@pair S T)) -/st. rewrite map_inj_in_uniq // allpairs_uniq_dep {Us Ut st inj_f}//. by apply: in2W => -[x1 y1] [x2 y2] /= [-> ->]. Qed.
Lemma
allpairs_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allpairs_uniq_dep", "apply", "inj_f", "map_allpairs", "map_inj_in_uniq", "seq", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel xs ys
:= all [pred x | all (r x) ys] xs.
Definition
allrel
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel0l ys : allrel [::] ys.
Proof. by []. Qed.
Lemma
allrel0l
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel0r xs : allrel xs [::].
Proof. by elim: xs. Qed.
Lemma
allrel0r
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_consl x xs ys : allrel (x :: xs) ys = all (r x) ys && allrel xs ys.
Proof. by []. Qed.
Lemma
allrel_consl
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_consr xs y ys : allrel xs (y :: ys) = all (r^~ y) xs && allrel xs ys.
Proof. exact: all_predI. Qed.
Lemma
allrel_consr
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all_predI", "allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_cons2 x y xs ys : allrel (x :: xs) (y :: ys) = [&& r x y, all (r x) ys, all (r^~ y) xs & allrel xs ys].
Proof. by rewrite /= allrel_consr -andbA. Qed.
Lemma
allrel_cons2
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "allrel", "allrel_consr" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel1l x ys : allrel [:: x] ys = all (r x) ys.
Proof. exact: andbT. Qed.
Lemma
allrel1l
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel1r xs y : allrel xs [:: y] = all (r^~ y) xs.
Proof. by rewrite allrel_consr allrel0r andbT. Qed.
Lemma
allrel1r
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "allrel", "allrel0r", "allrel_consr" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_catl xs xs' ys : allrel (xs ++ xs') ys = allrel xs ys && allrel xs' ys.
Proof. exact: all_cat. Qed.
Lemma
allrel_catl
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_cat", "allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_catr xs ys ys' : allrel xs (ys ++ ys') = allrel xs ys && allrel xs ys'.
Proof. elim: ys => /= [|y ys ihys]; first by rewrite allrel0r. by rewrite !allrel_consr ihys andbA. Qed.
Lemma
allrel_catr
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "allrel0r", "allrel_consr" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_maskl m xs ys : allrel xs ys -> allrel (mask m xs) ys.
Proof. by elim: m xs => [|[] m IHm] [|x xs] //= /andP [xys /IHm->]; rewrite ?xys. Qed.
Lemma
allrel_maskl
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "mask" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_maskr m xs ys : allrel xs ys -> allrel xs (mask m ys).
Proof. by elim: xs => //= x xs IHxs /andP [/all_mask->]. Qed.
Lemma
allrel_maskr
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_mask", "allrel", "mask" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_filterl a xs ys : allrel xs ys -> allrel (filter a xs) ys.
Proof. by rewrite filter_mask; apply: allrel_maskl. Qed.
Lemma
allrel_filterl
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "allrel_maskl", "apply", "filter", "filter_mask" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_filterr a xs ys : allrel xs ys -> allrel xs (filter a ys).
Proof. by rewrite filter_mask; apply: allrel_maskr. Qed.
Lemma
allrel_filterr
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "allrel_maskr", "apply", "filter", "filter_mask" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_allpairsE xs ys : allrel xs ys = all id [seq r x y | x <- xs, y <- ys].
Proof. by elim: xs => //= x xs ->; rewrite all_cat all_map. Qed.
Lemma
allrel_allpairsE
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all_cat", "all_map", "allrel", "id", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all2rel r xs
:= (allrel r xs xs).
Notation
all2rel
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sub_in_allrel {T S : Type} (P : {pred T}) (Q : {pred S}) (r r' : T -> S -> bool) : {in P & Q, forall x y, r x y -> r' x y} -> forall xs ys, all P xs -> all Q ys -> allrel r xs ys -> allrel r' xs ys.
Proof. move=> rr' + ys; elim=> //= x xs IHxs /andP [Px Pxs] Qys. rewrite !allrel_consl => /andP [+ {}/IHxs-> //]; rewrite andbT. by elim: ys Qys => //= y ys IHys /andP [Qy Qys] /andP [/rr'-> // /IHys->]. Qed.
Lemma
sub_in_allrel
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "Px", "all", "allrel", "allrel_consl" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sub_allrel {T S : Type} (r r' : T -> S -> bool) : (forall x y, r x y -> r' x y) -> forall xs ys, allrel r xs ys -> allrel r' xs ys.
Proof. by move=> rr' xs ys; apply/sub_in_allrel/all_predT/all_predT; apply: in2W. Qed.
Lemma
sub_allrel
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_predT", "allrel", "apply", "sub_in_allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_in_allrel {T S : Type} (P : {pred T}) (Q : {pred S}) r r' : {in P & Q, r =2 r'} -> forall xs ys, all P xs -> all Q ys -> allrel r xs ys = allrel r' xs ys.
Proof. move=> rr' xs ys Pxs Qys. by apply/idP/idP; apply/sub_in_allrel/Qys/Pxs => ? ? ? ?; rewrite rr'. Qed.
Lemma
eq_in_allrel
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "allrel", "apply", "sub_in_allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_allrel {T S : Type} (r r' : T -> S -> bool) : r =2 r' -> allrel r =2 allrel r'.
Proof. by move=> rr' xs ys; apply/eq_in_allrel/all_predT/all_predT. Qed.
Lemma
eq_allrel
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_predT", "allrel", "apply", "eq_in_allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrelC {T S : Type} (r : T -> S -> bool) xs ys : allrel r xs ys = allrel (fun y => r^~ y) ys xs.
Proof. by elim: xs => [|x xs ih]; [elim: ys | rewrite allrel_consr -ih]. Qed.
Lemma
allrelC
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "allrel_consr" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_mapl {T T' S : Type} (f : T' -> T) (r : T -> S -> bool) xs ys : allrel r (map f xs) ys = allrel (fun x => r (f x)) xs ys.
Proof. exact: all_map. Qed.
Lemma
allrel_mapl
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "T'", "all_map", "allrel", "map" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_mapr {T S S' : Type} (f : S' -> S) (r : T -> S -> bool) xs ys : allrel r xs (map f ys) = allrel (fun x y => r x (f y)) xs ys.
Proof. by rewrite allrelC allrel_mapl allrelC. Qed.
Lemma
allrel_mapr
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "allrelC", "allrel_mapl", "map" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrelP {T S : eqType} {r : T -> S -> bool} {xs ys} : reflect {in xs & ys, forall x y, r x y} (allrel r xs ys).
Proof. by rewrite allrel_allpairsE; exact: all_allpairsP. Qed.
Lemma
allrelP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_allpairsP", "allrel", "allrel_allpairsE" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrelT {T S : Type} (xs : seq T) (ys : seq S) : allrel (fun _ _ => true) xs ys = true.
Proof. by elim: xs => //= ? ?; rewrite allrel_consl all_predT. Qed.
Lemma
allrelT
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_predT", "allrel", "allrel_consl", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_relI {T S : Type} (r r' : T -> S -> bool) xs ys : allrel (fun x y => r x y && r' x y) xs ys = allrel r xs ys && allrel r' xs ys.
Proof. by rewrite -all_predI; apply: eq_all => ?; rewrite /= -all_predI. Qed.
Lemma
allrel_relI
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_predI", "allrel", "apply", "eq_all" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_revl {T S : Type} (r : T -> S -> bool) (s1 : seq T) (s2 : seq S) : allrel r (rev s1) s2 = allrel r s1 s2.
Proof. exact: all_rev. Qed.
Lemma
allrel_revl
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_rev", "allrel", "rev", "s1", "s2", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_revr {T S : Type} (r : T -> S -> bool) (s1 : seq T) (s2 : seq S) : allrel r s1 (rev s2) = allrel r s1 s2.
Proof. by rewrite allrelC allrel_revl allrelC. Qed.
Lemma
allrel_revr
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "allrelC", "allrel_revl", "rev", "s1", "s2", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
allrel_rev2 {T S : Type} (r : T -> S -> bool) (s1 : seq T) (s2 : seq S) : allrel r (rev s1) (rev s2) = allrel r s1 s2.
Proof. by rewrite allrel_revr allrel_revl. Qed.
Lemma
allrel_rev2
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "allrel_revl", "allrel_revr", "rev", "s1", "s2", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_allrel_meml {T : eqType} {S} (r : T -> S -> bool) (s1 s1' : seq T) s2 : s1 =i s1' -> allrel r s1 s2 = allrel r s1' s2.
Proof. by move=> eqs1; apply: eq_all_r. Qed.
Lemma
eq_allrel_meml
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "apply", "eq_all_r", "s1", "s2", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_allrel_memr {T} {S : eqType} (r : T -> S -> bool) s1 (s2 s2' : seq S) : s2 =i s2' -> allrel r s1 s2 = allrel r s1 s2'.
Proof. by rewrite ![allrel _ s1 _]allrelC; apply: eq_allrel_meml. Qed.
Lemma
eq_allrel_memr
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "allrelC", "apply", "eq_allrel_meml", "s1", "s2", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_allrel_mem2 {T S : eqType} (r : T -> S -> bool) (s1 s1' : seq T) (s2 s2' : seq S) : s1 =i s1' -> s2 =i s2' -> allrel r s1 s2 = allrel r s1' s2'.
Proof. by move=> /eq_allrel_meml -> /eq_allrel_memr ->. Qed.
Lemma
eq_allrel_mem2
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allrel", "eq_allrel_meml", "eq_allrel_memr", "s1", "s2", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
(rsym : symmetric r).
Hypothesis
rsym
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all2rel1 x : all2rel r [:: x] = r x x.
Proof. by rewrite /allrel /= !andbT. Qed.
Lemma
all2rel1
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all2rel", "allrel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all2rel2 x y : all2rel r [:: x; y] = r x x && r y y && r x y.
Proof. by rewrite /allrel /= rsym; do 3 case: r. Qed.
Lemma
all2rel2
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all2rel", "allrel", "rsym" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
all2rel_cons x xs : all2rel r (x :: xs) = [&& r x x, all (r x) xs & all2rel r xs].
Proof. rewrite allrel_cons2; congr andb; rewrite andbA -all_predI; congr andb. by elim: xs => //= y xs ->; rewrite rsym andbb. Qed.
Lemma
all2rel_cons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "all2rel", "all_predI", "allrel_cons2", "rsym" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise xs : bool
:= if xs is x :: xs then all (r x) xs && pairwise xs else true.
Fixpoint
pairwise
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_cons x xs : pairwise (x :: xs) = all (r x) xs && pairwise xs.
Proof. by []. Qed.
Lemma
pairwise_cons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "pairwise" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_cat xs ys : pairwise (xs ++ ys) = [&& allrel r xs ys, pairwise xs & pairwise ys].
Proof. by elim: xs => //= x xs ->; rewrite all_cat -!andbA; bool_congr. Qed.
Lemma
pairwise_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_cat", "allrel", "pairwise" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_rcons xs x : pairwise (rcons xs x) = all (r^~ x) xs && pairwise xs.
Proof. by rewrite -cats1 pairwise_cat allrel1r andbT. Qed.
Lemma
pairwise_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "allrel1r", "cats1", "pairwise", "pairwise_cat", "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise2 x y : pairwise [:: x; y] = r x y.
Proof. by rewrite /= !andbT. Qed.
Lemma
pairwise2
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "pairwise" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_mask m xs : pairwise xs -> pairwise (mask m xs).
Proof. by elim: m xs => [|[] m IHm] [|x xs] //= /andP [? ?]; rewrite ?IHm // all_mask. Qed.
Lemma
pairwise_mask
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_mask", "mask", "pairwise" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_filter a xs : pairwise xs -> pairwise (filter a xs).
Proof. by rewrite filter_mask; apply: pairwise_mask. Qed.
Lemma
pairwise_filter
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "filter", "filter_mask", "pairwise", "pairwise_mask" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwiseP x0 xs : reflect {in gtn (size xs) &, {homo nth x0 xs : i j / i < j >-> r i j}} (pairwise xs).
Proof. elim: xs => /= [|x xs IHxs]; first exact: (iffP idP). apply: (iffP andP) => [[r_x_xs pxs] i j|Hnth]; rewrite -?topredE /= ?ltnS. by case: i j => [|i] [|j] //= gti gtj ij; [exact/all_nthP | exact/IHxs]. split; last by apply/IHxs => // i j; apply/(Hnth i.+1 j.+1). by apply/(all_nthP x0) => i gti; apply/(Hnth 0 i...
Lemma
pairwiseP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_nthP", "apply", "gtn", "last", "ltnS", "nth", "pairwise", "size", "split" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_all2rel : reflexive r -> symmetric r -> forall xs, pairwise xs = all2rel r xs.
Proof. by move=> r_refl r_sym; elim => //= x xs ->; rewrite all2rel_cons // r_refl. Qed.
Lemma
pairwise_all2rel
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all2rel", "all2rel_cons", "pairwise" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sub_in_pairwise {T : Type} (P : {pred T}) (r r' : rel T) : {in P &, subrel r r'} -> forall xs, all P xs -> pairwise r xs -> pairwise r' xs.
Proof. move=> rr'; elim=> //= x xs IHxs /andP [Px Pxs] /andP [+ {}/IHxs->] //. rewrite andbT; elim: xs Pxs => //= x' xs IHxs /andP [? ?] /andP [+ /IHxs->] //. by rewrite andbT; apply: rr'. Qed.
Lemma
sub_in_pairwise
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "Px", "all", "apply", "pairwise", "rel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sub_pairwise {T : Type} (r r' : rel T) xs : subrel r r' -> pairwise r xs -> pairwise r' xs.
Proof. by move=> rr'; apply/sub_in_pairwise/all_predT; apply: in2W. Qed.
Lemma
sub_pairwise
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_predT", "apply", "pairwise", "rel", "sub_in_pairwise" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_in_pairwise {T : Type} (P : {pred T}) (r r' : rel T) : {in P &, r =2 r'} -> forall xs, all P xs -> pairwise r xs = pairwise r' xs.
Proof. move=> rr' xs Pxs. by apply/idP/idP; apply/sub_in_pairwise/Pxs => ? ? ? ?; rewrite rr'. Qed.
Lemma
eq_in_pairwise
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "apply", "pairwise", "rel", "sub_in_pairwise" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_pairwise {T : Type} (r r' : rel T) : r =2 r' -> pairwise r =i pairwise r'.
Proof. by move=> rr' xs; apply/eq_in_pairwise/all_predT. Qed.
Lemma
eq_pairwise
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_predT", "apply", "eq_in_pairwise", "pairwise", "rel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_map {T T' : Type} (f : T' -> T) (r : rel T) xs : pairwise r (map f xs) = pairwise (relpre f r) xs.
Proof. by elim: xs => //= x xs ->; rewrite all_map. Qed.
Lemma
pairwise_map
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "T'", "all_map", "map", "pairwise", "rel" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_relI {T : Type} (r r' : rel T) (s : seq T) : pairwise [rel x y | r x y && r' x y] s = pairwise r s && pairwise r' s.
Proof. by elim: s => //= x s ->; rewrite andbACA all_predI. Qed.
Lemma
pairwise_relI
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_predI", "pairwise", "rel", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
subseq_pairwise xs ys : subseq xs ys -> pairwise r ys -> pairwise r xs.
Proof. by case/subseqP => m _ ->; apply: pairwise_mask. Qed.
Lemma
subseq_pairwise
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "pairwise", "pairwise_mask", "subseq", "subseqP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
uniq_pairwise xs : uniq xs = pairwise [rel x y | x != y] xs.
Proof. elim: xs => //= x xs ->; congr andb; rewrite -has_pred1 -all_predC. by elim: xs => //= x' xs ->; case: eqVneq. Qed.
Lemma
uniq_pairwise
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all_predC", "eqVneq", "has_pred1", "pairwise", "rel", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_uniq xs : irreflexive r -> pairwise r xs -> uniq xs.
Proof. move=> r_irr; rewrite uniq_pairwise; apply/sub_pairwise => x y. by apply: contraTneq => ->; rewrite r_irr. Qed.
Lemma
pairwise_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "contraTneq", "pairwise", "sub_pairwise", "uniq", "uniq_pairwise" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_eq : antisymmetric r -> forall xs ys, pairwise r xs -> pairwise r ys -> perm_eq xs ys -> xs = ys.
Proof. move=> r_asym; elim=> [|x xs IHxs] [|y ys] //=; try by move=> ? ? /perm_size. move=> /andP [r_x_xs pxs] /andP [r_y_ys pys] eq_xs_ys. move: (mem_head y ys) (mem_head x xs). rewrite -(perm_mem eq_xs_ys) [x \in _](perm_mem eq_xs_ys) !inE. case: eqVneq eq_xs_ys => /= [->|ne_xy] eq_xs_ys ys_x xs_y. by rewrite (IHxs...
Lemma
pairwise_eq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allP", "apply", "eqVneq", "inE", "mem_head", "pairwise", "perm_cons", "perm_eq", "perm_mem", "perm_size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pairwise_trans s : antisymmetric r -> pairwise r s -> {in s & &, transitive r}.
Proof. move=> /(_ _ _ _)/eqP r_anti + y x z => /pairwiseP-/(_ y) ltP ys xs zs. have [-> //|neqxy] := eqVneq x y; have [-> //|neqzy] := eqVneq z y. move=> lxy lyz; move: ys xs zs lxy neqxy lyz neqzy. move=> /(nthP y)[j jlt <-] /(nthP y)[i ilt <-] /(nthP y)[k klt <-]. have [ltij|ltji|->] := ltngtP i j; last 2 first. - by...
Lemma
pairwise_trans
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "eqVneq", "last", "ltP", "ltn_trans", "ltngtP", "nthP", "pairwise", "pairwiseP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
incr_tally bs x
:= if bs isn't b :: bs then [:: (x, 1)] else if x == b.1 then (x, b.2.+1) :: bs else b :: incr_tally bs x.
Fixpoint
incr_tally
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tally s
:= foldl incr_tally [::] s.
Definition
tally
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "foldl", "incr_tally" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
wf_tally
:= [qualify a bs : seq (T * nat) | uniq (unzip1 bs) && (0 \notin unzip2 bs)].
Definition
wf_tally
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nat", "seq", "uniq", "unzip1", "unzip2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tally_seq bs
:= flatten [seq nseq b.2 b.1 | b <- bs].
Definition
tally_seq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "flatten", "nseq", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tseq
:= tally_seq.
Notation
tseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "tally_seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_tally_seq bs : size (tally_seq bs) = sumn (unzip2 bs).
Proof. by rewrite size_flatten /shape -map_comp; under eq_map do rewrite /= size_nseq. Qed.
Lemma
size_tally_seq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eq_map", "map_comp", "shape", "size", "size_flatten", "size_nseq", "sumn", "tally_seq", "unzip2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tally_seqK : {in wf_tally, cancel tally_seq tally}.
Proof. move=> bs /andP[]; elim: bs => [|[x [|n]] bs IHbs] //= /andP[bs'x Ubs] bs'0. rewrite inE /tseq /tally /= -[n.+1]addn1 in bs'0 *. elim: n 1 => /= [|n IHn] m; last by rewrite eqxx IHn addnS. rewrite -{}[in RHS]IHbs {Ubs bs'0}// /tally /tally_seq add0n. elim: bs bs'x [::] => [|[y n] bs IHbs] //= /[1!inE] /norP[y'x ...
Lemma
tally_seqK
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "add0n", "addn1", "addnS", "eq_sym", "eqxx", "inE", "last", "tally", "tally_seq", "tseq", "wf_tally" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
incr_tallyP x : {homo incr_tally^~ x : bs / bs \in wf_tally}.
Proof. move=> bs /andP[]; rewrite unfold_in. elim: bs => [|[y [|n]] bs IHbs] //= /andP[bs'y Ubs] /[1!inE] /= bs'0. have [<- | y'x] /= := eqVneq y; first by rewrite bs'y Ubs. rewrite -andbA {}IHbs {Ubs bs'0}// andbT. elim: bs bs'y => [|b bs IHbs] /=; rewrite inE ?y'x // => /norP[b'y bs'y]. by case: ifP => _; rewrite /= ...
Lemma
incr_tallyP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eqVneq", "inE", "incr_tally", "wf_tally" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tallyP s : tally s \is a wf_tally.
Proof. rewrite /tally; set bs := [::]; have: bs \in wf_tally by []. by elim: s bs => //= x s IHs bs /(incr_tallyP x)/IHs. Qed.
Lemma
tallyP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "incr_tallyP", "tally", "wf_tally" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tallyK s : perm_eq (tally_seq (tally s)) s.
Proof. rewrite -[s in perm_eq _ s]cats0 -[nil]/(tseq [::]) /tally. elim: s [::] => //= x s IHs bs; rewrite {IHs}(permPl (IHs _)). rewrite perm_sym -cat1s perm_catCA {s}perm_cat2l. elim: bs => //= b bs IHbs; case: eqP => [-> | _] //=. by rewrite -cat1s perm_catCA perm_cat2l. Qed.
Lemma
tallyK
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat1s", "cats0", "permPl", "perm_cat2l", "perm_catCA", "perm_eq", "perm_sym", "tally", "tally_seq", "tseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tallyEl s : perm_eq (unzip1 (tally s)) (undup s).
Proof. have /andP[Ubs bs'0] := tallyP s; set bs := tally s in Ubs bs'0 *. rewrite uniq_perm ?undup_uniq {Ubs}// => x. rewrite mem_undup -(perm_mem (tallyK s)) -/bs. elim: bs => [|[y [|m]] bs IHbs] //= in bs'0 *. by rewrite inE IHbs // mem_cat mem_nseq. Qed.
Lemma
tallyEl
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "inE", "mem_cat", "mem_nseq", "mem_undup", "perm_eq", "perm_mem", "tally", "tallyK", "tallyP", "undup", "undup_uniq", "uniq_perm", "unzip1" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tallyE s : perm_eq (tally s) [seq (x, count_mem x s) | x <- undup s].
Proof. have /andP[Ubs _] := tallyP s; pose b := [fun s x => (x, count_mem x (tseq s))]. suffices /permPl->: perm_eq (tally s) (map (b (tally s)) (unzip1 (tally s))). congr perm_eq: (perm_map (b (tally s)) (tallyEl s)). by under eq_map do rewrite /= (permP (tallyK s)). elim: (tally s) Ubs => [|[x m] bs IH] //= /andP...
Lemma
tallyE
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn0", "apply", "count_cat", "count_mem", "count_memPn", "count_nseq", "eq_in_map", "eq_map", "eqxx", "inE", "map", "memPnC", "mem_cat", "mem_nseq", "mul1n", "permP", "permPl", "perm_cons", "perm_eq", "perm_map", "seq", "tally", "tallyEl", "tallyK", "tallyP", "tse...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
perm_tally s1 s2 : perm_eq s1 s2 -> perm_eq (tally s1) (tally s2).
Proof. move=> eq_s12; apply: (@perm_trans _ [seq (x, count_mem x s2) | x <- undup s1]). by congr perm_eq: (tallyE s1); under eq_map do rewrite (permP eq_s12). by rewrite (permPr (tallyE s2)); apply/perm_map/perm_undup/(perm_mem eq_s12). Qed.
Lemma
perm_tally
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "count_mem", "eq_map", "permP", "permPr", "perm_eq", "perm_map", "perm_mem", "perm_trans", "perm_undup", "s1", "s2", "seq", "tally", "tallyE", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
perm_tally_seq bs1 bs2 : perm_eq bs1 bs2 -> perm_eq (tally_seq bs1) (tally_seq bs2).
Proof. by move=> Ebs12; rewrite perm_flatten ?perm_map. Qed.
Lemma
perm_tally_seq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "perm_eq", "perm_flatten", "perm_map", "tally_seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
perm_tseq
:= perm_tally_seq.
Notation
perm_tseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "perm_tally_seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
perm_count_undup s : perm_eq (flatten [seq nseq (count_mem x s) x | x <- undup s]) s.
Proof. by rewrite -(permPr (tallyK s)) (permPr (perm_tseq (tallyE s))) /tseq -map_comp. Qed.
Lemma
perm_count_undup
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "count_mem", "flatten", "map_comp", "nseq", "permPr", "perm_eq", "perm_tseq", "seq", "tallyE", "tallyK", "tseq", "undup" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cons_perms_ perms_rec (s : seq T) bs bs2 acc
:= if bs isn't b :: bs1 then acc else if b isn't (x, m.+1) then cons_perms_ perms_rec s bs1 bs2 acc else let acc_xs := perms_rec (x :: s) ((x, m) :: bs1 ++ bs2) acc in cons_perms_ perms_rec s bs1 (b :: bs2) acc_xs.
Fixpoint
cons_perms_
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "perms_rec", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
perms_rec n s bs acc
:= if n isn't n.+1 then s :: acc else cons_perms_ (perms_rec n) s bs [::] acc.
Fixpoint
perms_rec
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cons_perms_" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cons_perms n
:= (cons_perms_ (perms_rec n) [::]).
Notation
cons_perms
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cons_perms_", "perms_rec" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
permutations s
:= perms_rec (size s) [::] (tally s) [::].
Definition
permutations
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "perms_rec", "size", "tally" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
permsP s : exists n bs, [/\ permutations s = perms_rec n [::] bs [::], size (tseq bs) == n, perm_eq (tseq bs) s & uniq (unzip1 bs)].
Proof. have /andP[Ubs _] := tallyP s; exists (size s), (tally s). by rewrite (perm_size (tallyK s)) tallyK. Qed.
Let
permsP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "perm_eq", "perm_size", "perms_rec", "permutations", "size", "tally", "tallyK", "tallyP", "tseq", "uniq", "unzip1" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bsCA
:= (permEl (perm_catCA _ [:: _] _)).
Notation
bsCA
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "permEl", "perm_catCA" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cons_permsE : forall n x bs bs1 bs2, let cp := cons_perms n bs bs2 in let perms s := perms_rec n s bs1 [::] in cp (perms [:: x]) = cp [::] ++ [seq rcons t x | t <- perms [::]].
Proof. pose is_acc f := forall acc, f acc = f [::] ++ acc. (* f is accumulating. *) have cpE: forall f & forall s bs, is_acc (f s bs), is_acc (cons_perms_ f _ _ _). move=> s bs bs2 f fE acc; elim: bs => [|[x [|m]] bs IHbs] //= in s bs2 acc *. by rewrite fE IHbs catA -IHbs. have prE: is_acc (perms_rec _ _ _) by elim...
Let
cons_permsE
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "catA", "cats1", "cons_perms", "cons_perms_", "cp", "eq_map", "fE", "map_cat", "map_comp", "perms", "perms_rec", "rcons", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
mem_permutations s t : (t \in permutations s) = perm_eq t s.
Proof. have{s} [n [bs [-> Dn /permPr<- _]]] := permsP s. elim: n => [|n IHn] /= in t bs Dn *. by rewrite inE (nilP Dn); apply/eqP/perm_nilP. rewrite -[bs in tseq bs]cats0 in Dn *; have x0 : T by case: (tseq _) Dn. rewrite -[RHS](@andb_idl (last x0 t \in tseq bs)). case/lastP: t {IHn} => [|t x] Dt; first by rewrite ...
Lemma
mem_permutations
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "bsCA", "cat_cons", "cats0", "cons_permsE", "inE", "last", "lastP", "last_rcons", "mapP", "mem_cat", "mem_head", "mem_nseq", "mem_rcons", "nilP", "permPr", "perm_cons", "perm_eq", "perm_mem", "perm_nilP", "perm_rcons", "perm_size", "perm_tseq", "permsP", "per...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
permutations_uniq s : uniq (permutations s).
Proof. have{s} [n [bs [-> Dn _ Ubs]]] := permsP s. elim: n => //= n IHn in bs Dn Ubs *; rewrite -[bs]cats0 /unzip1 in Dn Ubs. elim: bs [::] => [|[x [|m]] bs IHbs] //= bs2 in Dn Ubs *. by case/andP: Ubs => _ /IHbs->. rewrite /= cons_permsE cat_uniq has_sym andbCA andbC. rewrite {}IHbs; first 1 last; last by rewrite (p...
Lemma
permutations_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "bsCA", "cat_uniq", "cats0", "cons_permsE", "hasPn", "has_cat", "has_map", "has_sym", "inE", "last", "mapP", "map_cat", "map_inj_uniq", "mem_cat", "perm_map", "perm_size", "perm_tseq", "perm_uniq", "permsP", "perms_rec", "permutations", "rcons_inj", "rcons_injl...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
perms
:= permutations.
Notation
perms
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "permutations" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
permutationsE s : 0 < size s -> perm_eq (perms s) [seq x :: t | x <- undup s, t <- perms (rem x s)].
Proof. move=> nt_s; apply/uniq_perm=> [||t]; first exact: permutations_uniq. apply/allpairs_uniq_dep=> [|x _|]; rewrite ?undup_uniq ?permutations_uniq //. by case=> [_ _] [x t] _ _ [-> ->]. rewrite mem_permutations; apply/idP/allpairsPdep=> [Dt | [x [t1 []]]]. rewrite -(perm_size Dt) in nt_s; case: t nt_s => // ...
Lemma
permutationsE
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "allpairsPdep", "allpairs_uniq_dep", "apply", "mem_head", "mem_permutations", "mem_undup", "permPl", "perm_cons", "perm_eq", "perm_mem", "perm_size", "perm_sym", "perm_to_rem", "perms", "permutations_uniq", "rem", "seq", "size", "split", "undup", "undup_uniq", "uniq_perm" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
permutationsErot x s (le_x := fun t => iota 0 (index x t + 1)) : perm_eq (perms (x :: s)) [seq rot i (x :: t) | t <- perms s, i <- le_x t].
Proof. have take'x t i: i <= index x t -> i <= size t /\ x \notin take i t. move=> le_i_x; have le_i_t: i <= size t := leq_trans le_i_x (index_size x t). case: (nthP x) => // -[j lt_j_i /eqP]; rewrite size_takel // in lt_j_i. by rewrite nth_take // [_ == _](before_find x (leq_trans lt_j_i le_i_x)). pose xrot t i ...
Lemma
permutationsErot
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn0", "addn1", "allpairsPdep", "allpairs_uniq_dep", "apply", "before_find", "cat_cons", "cat_rcons", "drop", "drop_nth", "eqxx", "index", "index_cat", "index_mem", "index_size", "iota", "iota_uniq", "leq_addr", "leq_trans", "leqnn", "ltnS", "mem_head", "mem_iota", "m...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_permutations s : uniq s -> size (permutations s) = (size s)`!.
Proof. move Dn: (size s) => n Us; elim: n s => [[]|n IHn s] //= in Dn Us *. rewrite (perm_size (permutationsE _)) ?Dn // undup_id // factS -Dn. rewrite -(size_iota 0 n`!) -(size_allpairs (fun=>id)) !size_allpairs_dep. by apply/congr1/eq_in_map=> x sx; rewrite size_iota IHn ?size_rem ?Dn ?rem_uniq. Qed.
Lemma
size_permutations
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "eq_in_map", "factS", "id", "perm_size", "permutations", "permutationsE", "rem_uniq", "size", "size_allpairs", "size_allpairs_dep", "size_iota", "size_rem", "undup_id", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
permutations_all_uniq s : uniq s -> all uniq (permutations s).
Proof. by move=> Us; apply/allP=> t; rewrite mem_permutations => /perm_uniq->. Qed.
Lemma
permutations_all_uniq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "all", "allP", "apply", "mem_permutations", "perm_uniq", "permutations", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
perm_permutations s t : perm_eq s t -> perm_eq (permutations s) (permutations t).
Proof. move=> Est; apply/uniq_perm; try exact: permutations_uniq. by move=> u; rewrite !mem_permutations (permPr Est). Qed.
Lemma
perm_permutations
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "mem_permutations", "permPr", "perm_eq", "permutations", "permutations_uniq", "uniq_perm" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
change_type ty ty' (x : ty) (strategy : ty = ty') : ty'
:= ecast ty ty strategy x.
Definition
change_type
boot
boot/ssrAC.v
[ "HB", "structures", "Corelib", "PosDef", "mathcomp", "ssreflect", "ssrbool", "ssrfun", "ssrnat", "eqtype", "seq", "bigop", "Pos", "AC.Syntax", "AC.Exports" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
simplrefl
:= (ltac: (simpl; reflexivity)) (only parsing).
Notation
simplrefl
boot
boot/ssrAC.v
[ "HB", "structures", "Corelib", "PosDef", "mathcomp", "ssreflect", "ssrbool", "ssrfun", "ssrnat", "eqtype", "seq", "bigop", "Pos", "AC.Syntax", "AC.Exports" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cbvrefl
:= (ltac: (cbv; reflexivity)) (only parsing).
Notation
cbvrefl
boot
boot/ssrAC.v
[ "HB", "structures", "Corelib", "PosDef", "mathcomp", "ssreflect", "ssrbool", "ssrfun", "ssrnat", "eqtype", "seq", "bigop", "Pos", "AC.Syntax", "AC.Exports" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
vmrefl
:= (ltac: (vm_compute; reflexivity)) (only parsing).
Notation
vmrefl
boot
boot/ssrAC.v
[ "HB", "structures", "Corelib", "PosDef", "mathcomp", "ssreflect", "ssrbool", "ssrfun", "ssrnat", "eqtype", "seq", "bigop", "Pos", "AC.Syntax", "AC.Exports" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
ten
:= (xO (xI (xO xH))).
Notation
ten
boot
boot/ssrAC.v
[ "HB", "structures", "Corelib", "PosDef", "mathcomp", "ssreflect", "ssrbool", "ssrfun", "ssrnat", "eqtype", "seq", "bigop", "Pos", "AC.Syntax", "AC.Exports" ]
[]
** Conversion with a decimal representation for printing/parsing
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
of_uint_acc (d:Decimal.uint) (acc:positive)
:= match d with | Decimal.Nil => acc | Decimal.D0 l => of_uint_acc l (mul ten acc) | Decimal.D1 l => of_uint_acc l (add 1 (mul ten acc)) | Decimal.D2 l => of_uint_acc l (add 1~0 (mul ten acc)) | Decimal.D3 l => of_uint_acc l (add 1~1 (mul ten acc)) | Decimal.D4 l => of_uint_acc l (add 1~0~0 (mul ten acc))...
Fixpoint
of_uint_acc
boot
boot/ssrAC.v
[ "HB", "structures", "Corelib", "PosDef", "mathcomp", "ssreflect", "ssrbool", "ssrfun", "ssrnat", "eqtype", "seq", "bigop", "Pos", "AC.Syntax", "AC.Exports" ]
[ "Nil", "add", "mul", "ten" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d