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
ffact_fact n m : m <= n -> n ^_ m * (n - m)`! = n`!.
Proof. by elim: n m => [|n IHn] [|m] //= le_m_n; rewrite ?mul1n // -mulnA IHn. Qed.
Lemma
ffact_fact
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "mul1n", "mulnA" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
ffact_factd n m : m <= n -> n ^_ m = n`! %/ (n - m)`!.
Proof. by move/ffact_fact <-; rewrite mulnK ?fact_gt0. Qed.
Lemma
ffact_factd
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "fact_gt0", "ffact_fact", "mulnK" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
binomial n m
:= match n, m with | n'.+1, m'.+1 => binomial n' m + binomial n' m' | _, 0 => 1 | 0, _.+1 => 0 end.
Fixpoint
binomial
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "n'" ]
Binomial coefficients
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
"''C' ( n , m )"
:= (binomial n m) : nat_scope.
Notation
''C' ( n , m )
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "binomial" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
binE n m : binomial n m = match n, m with | n'.+1, m'.+1 => binomial n' m + binomial n' m' | _, 0 => 1 | 0, _.+1 => 0 end.
Proof. by case: n. Qed.
Lemma
binE
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "binomial", "n'" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin0 n : 'C(n, 0) = 1.
Proof. by case: n. Qed.
Lemma
bin0
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin0n m : 'C(0, m) = (m == 0).
Proof. by case: m. Qed.
Lemma
bin0n
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
binS n m : 'C(n.+1, m.+1) = 'C(n, m.+1) + 'C(n, m).
Proof. by []. Qed.
Lemma
binS
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin1 n : 'C(n, 1) = n.
Proof. by elim: n => //= n IHn; rewrite binS bin0 IHn addn1. Qed.
Lemma
bin1
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "addn1", "bin0", "binS" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin_gt0 n m : (0 < 'C(n, m)) = (m <= n).
Proof. by elim: n m => [|n IHn] [|m] //; rewrite addn_gt0 !IHn orbC ltn_neqAle andKb. Qed.
Lemma
bin_gt0
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "addn_gt0", "andKb", "ltn_neqAle" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
leq_bin2l n1 n2 m : n1 <= n2 -> 'C(n1, m) <= 'C(n2, m).
Proof. by elim: n1 n2 m => [|n1 IHn] [|n2] [|n] le_n12 //; rewrite leq_add ?IHn. Qed.
Lemma
leq_bin2l
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "leq_add" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin_small n m : n < m -> 'C(n, m) = 0.
Proof. by rewrite ltnNge -bin_gt0; case: posnP. Qed.
Lemma
bin_small
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin_gt0", "ltnNge", "posnP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
binn n : 'C(n, n) = 1.
Proof. by elim: n => [|n IHn] //; rewrite binS bin_small. Qed.
Lemma
binn
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "binS", "bin_small" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
mul_bin_diag n m : n * 'C(n.-1, m) = m.+1 * 'C(n, m.+1).
Proof. rewrite [RHS]mulnC; elim: n m => [|[|n] IHn] [|m] //=; first by rewrite bin1. by rewrite mulSn [in _ * _]binS mulnDr addnCA !IHn -mulnS -mulnDl -binS. Qed.
Lemma
mul_bin_diag
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "addnCA", "bin1", "binS", "mulSn", "mulnC", "mulnDl", "mulnDr", "mulnS" ]
Multiply to move diagonally down and right in the Pascal triangle.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin_fact n m : m <= n -> 'C(n, m) * (m`! * (n - m)`!) = n`!.
Proof. elim: n m => [|n IHn] [|m] // le_m_n; first by rewrite bin0 !mul1n. by rewrite !factS -!mulnA mulnCA mulnA -mul_bin_diag -mulnA IHn. Qed.
Lemma
bin_fact
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin0", "factS", "mul1n", "mul_bin_diag", "mulnA", "mulnCA" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin_factd n m : 0 < n -> 'C(n, m) = n`! %/ (m`! * (n - m)`!).
Proof. have [/bin_fact<-|*] := leqP m n; first by rewrite mulnK ?muln_gt0 ?fact_gt0. by rewrite divnMA bin_small ?divn_small ?fact_gt0 ?ltn_fact. Qed.
Lemma
bin_factd
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin_fact", "bin_small", "divnMA", "divn_small", "fact_gt0", "leqP", "ltn_fact", "mulnK", "muln_gt0" ]
In fact the only exception for bin_factd is n = 0 and m = 1
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin_ffact n m : 'C(n, m) * m`! = n ^_ m.
Proof. have [lt_n_m | le_m_n] := ltnP n m; first by rewrite bin_small ?ffact_small. by rewrite ffact_factd // -(bin_fact le_m_n) mulnA mulnK ?fact_gt0. Qed.
Lemma
bin_ffact
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin_fact", "bin_small", "fact_gt0", "ffact_factd", "ffact_small", "ltnP", "mulnA", "mulnK" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin_ffactd n m : 'C(n, m) = n ^_ m %/ m`!.
Proof. by rewrite -bin_ffact mulnK ?fact_gt0. Qed.
Lemma
bin_ffactd
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin_ffact", "fact_gt0", "mulnK" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin_sub n m : m <= n -> 'C(n, n - m) = 'C(n, m).
Proof. by move=> le_m_n; rewrite !bin_ffactd !ffact_factd ?leq_subr // divnAC subKn. Qed.
Lemma
bin_sub
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin_ffactd", "divnAC", "ffact_factd", "leq_subr", "subKn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
mul_bin_down n m : n * 'C(n.-1, m) = (n - m) * 'C(n, m).
Proof. case: n => //= n; have [lt_n_m | le_m_n] := ltnP n m. by rewrite (eqnP lt_n_m) mulnC bin_small. by rewrite -!['C(_, m)]bin_sub ?leqW ?subSn ?mul_bin_diag. Qed.
Lemma
mul_bin_down
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin_small", "bin_sub", "eqnP", "leqW", "ltnP", "mul_bin_diag", "mulnC", "subSn" ]
Multiply to move down in the Pascal triangle.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
mul_bin_left n m : m.+1 * 'C(n, m.+1) = (n - m) * 'C(n, m).
Proof. by rewrite -mul_bin_diag mul_bin_down. Qed.
Lemma
mul_bin_left
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "mul_bin_diag", "mul_bin_down" ]
Multiply to move left in the Pascal triangle.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
binSn n : 'C(n.+1, n) = n.+1.
Proof. by rewrite -bin_sub ?leqnSn // subSnn bin1. Qed.
Lemma
binSn
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin1", "bin_sub", "leqnSn", "subSnn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin2 n : 'C(n, 2) = (n * n.-1)./2.
Proof. by rewrite -[n.-1]bin1 mul_bin_diag -divn2 mulKn. Qed.
Lemma
bin2
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin1", "divn2", "mulKn", "mul_bin_diag" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin2odd n : odd n -> 'C(n, 2) = n * n.-1./2.
Proof. by case: n => // n oddn; rewrite bin2 -!divn2 muln_divA ?dvdn2. Qed.
Lemma
bin2odd
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin2", "divn2", "dvdn2", "muln_divA", "odd", "oddn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
prime_dvd_bin k p : prime p -> 0 < k < p -> p %| 'C(p, k).
Proof. move=> p_pr /andP[k_gt0 lt_k_p]. suffices /Gauss_dvdr<-: coprime p (p - k) by rewrite -mul_bin_down dvdn_mulr. by rewrite prime_coprime // dvdn_subr 1?ltnW // gtnNdvd. Qed.
Lemma
prime_dvd_bin
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "Gauss_dvdr", "coprime", "dvdn_mulr", "dvdn_subr", "gtnNdvd", "ltnW", "mul_bin_down", "p_pr", "prime", "prime_coprime" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bin2_sum n : \sum_(0 <= i < n) i = 'C(n, 2).
Proof. elim: n => [|n IHn]; first by rewrite big_geq. by rewrite big_nat_recr // IHn binS bin1. Qed.
Lemma
bin2_sum
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "big_geq", "big_nat_recr", "bin1", "binS" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
triangular_sum
:= bin2_sum (only parsing).
Notation
triangular_sum
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "bin2_sum" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
expnDn a b n : (a + b) ^ n = \sum_(i < n.+1) 'C(n, i) * (a ^ (n - i) * b ^ i).
Proof. elim: n => [|n IHn]; rewrite big_ord_recl muln1 ?big_ord0 //. rewrite expnS {}IHn /= mulnDl !big_distrr /= big_ord_recl muln1 subn0. rewrite !big_ord_recr /= !binn !subnn bin0 !subn0 !mul1n -!expnS -addnA. congr (_ + _); rewrite addnA -big_split /=; congr (_ + _). apply: eq_bigr => i _; rewrite mulnCA (mulnA a) ...
Theorem
expnDn
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "addnA", "apply", "big_distrr", "big_ord0", "big_ord_recl", "big_ord_recr", "big_split", "bin0", "binn", "eq_bigr", "expnS", "expnSr", "mul1n", "muln1", "mulnA", "mulnC", "mulnCA", "mulnDl", "subn0", "subnSK", "subnn" ]
textbook proof of `bin2_sum`. Should be moved out of the main library, to a dedicated "showcase" library. Lemma textbook_triangular_sum n : \sum_(0 <= i < n) i = 'C(n, 2). Proof. rewrite bin2; apply: canRL half_double _. rewrite -addnn {1}big_nat_rev -big_split big_mkord /= ?add0n. rewrite (eq_bigr (fun _ => n.-1)); ...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
Pascal
:= expnDn.
Definition
Pascal
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "expnDn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
Vandermonde k l i : \sum_(j < i.+1) 'C(k, j) * 'C(l, i - j) = 'C(k + l , i).
Proof. pose f k i := \sum_(j < i.+1) 'C(k, j) * 'C(l, i - j). suffices{k i} fxx k i: f k.+1 i.+1 = f k i.+1 + f k i. elim: k i => [i | k IHk [|i]]; last by rewrite -/(f _ _) fxx /f !IHk -binS. by rewrite big_ord_recl big1_eq addn0 mul1n subn0. by rewrite big_ord_recl big_ord0 addn0 !bin0 muln1. rewrite {}/f big...
Lemma
Vandermonde
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "addn0", "addnA", "apply", "big1_eq", "big_ord0", "big_ord_recl", "big_split", "bin0", "binS", "eq_bigr", "last", "mul1n", "muln1", "mulnDl", "subn0" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
subn_exp m n k : m ^ k - n ^ k = (m - n) * (\sum_(i < k) m ^ (k.-1 -i) * n ^ i).
Proof. case: k => [|k]; first by rewrite big_ord0 muln0. rewrite mulnBl !big_distrr big_ord_recl big_ord_recr /= subn0 muln1. rewrite subnn mul1n -!expnS subnDA; congr (_ - _); apply: canRL (addnK _) _. congr (_ + _); apply: eq_bigr => i _. by rewrite (mulnCA n) -expnS mulnA -expnS subnSK /=. Qed.
Lemma
subn_exp
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "addnK", "apply", "big_distrr", "big_ord0", "big_ord_recl", "big_ord_recr", "eq_bigr", "expnS", "mul1n", "muln0", "muln1", "mulnA", "mulnBl", "mulnCA", "subn0", "subnDA", "subnSK", "subnn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
predn_exp m k : (m ^ k).-1 = m.-1 * (\sum_(i < k) m ^ i).
Proof. rewrite -!subn1 -[in LHS](exp1n k) subn_exp; congr (_ * _). symmetry; rewrite (reindex_inj rev_ord_inj); apply: eq_bigr => i _ /=. by rewrite -subn1 -subnDA exp1n muln1. Qed.
Lemma
predn_exp
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "apply", "eq_bigr", "exp1n", "muln1", "reindex_inj", "rev_ord_inj", "subn1", "subnDA", "subn_exp" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
dvdn_pred_predX n e : (n.-1 %| (n ^ e).-1)%N.
Proof. by rewrite predn_exp dvdn_mulr. Qed.
Lemma
dvdn_pred_predX
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "dvdn_mulr", "predn_exp" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
modn_summ I r (P : pred I) F d : \sum_(i <- r | P i) F i %% d = \sum_(i <- r | P i) F i %[mod d].
Proof. by apply/eqP; elim/big_rec2: _ => // i m n _; rewrite modnDml eqn_modDl. Qed.
Lemma
modn_summ
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "apply", "big_rec2", "eqn_modDl", "modnDml" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
prime_modn_expSn p n : prime p -> n.+1 ^ p = (n ^ p).+1 %[mod p].
Proof. case: p => // p pP. rewrite -[(_ ^ _).+1]addn0 (expnDn 1) big_ord_recr big_ord_recl /=. rewrite subnn binn exp1n !mul1n addnAC -modnDmr; congr ((_ + _) %% _). apply/eqP/dvdn_sum => -[i ?] _; exact/dvdn_mulr/prime_dvd_bin. Qed.
Lemma
prime_modn_expSn
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "addn0", "addnAC", "apply", "big_ord_recl", "big_ord_recr", "binn", "dvdn_mulr", "dvdn_sum", "exp1n", "expnDn", "modnDmr", "mul1n", "pP", "prime", "prime_dvd_bin", "subnn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
fermat_little a p : prime p -> a ^ p = a %[mod p].
Proof. move=> pP. elim: a => [|a IH]; first by rewrite exp0n // prime_gt0. by rewrite prime_modn_expSn // -addn1 -modnDml IH modnDml addn1. Qed.
Lemma
fermat_little
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "addn1", "exp0n", "modnDml", "pP", "prime", "prime_gt0", "prime_modn_expSn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
card_uniq_tuples T n (A : pred T) : #|[set t : n.-tuple T | all A t & uniq t]| = #|A| ^_ n.
Proof. elim: n A => [|n IHn] A. by rewrite (@eq_card1 _ [tuple]) // => t; rewrite [t]tuple0 inE. rewrite -sum1dep_card (partition_big (@thead _ _) A) /= => [t|]. by case/tupleP: t => x t; do 2!case/andP. rewrite ffactnS -sum_nat_const; apply: eq_bigr => x Ax. rewrite (cardD1 x) [x \in A]Ax /= -(IHn [predD1 A & x]) ...
Lemma
card_uniq_tuples
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "all", "all_predC", "all_predI", "apply", "behead", "cardD1", "eq_bigl", "eq_bigr", "eq_card1", "eqxx", "ffactnS", "has_pred1", "inE", "partition_big", "predD1", "reindex", "sum1dep_card", "sum_nat_const", "thead", "theadE", "tuple", "tuple0", "tupleP", "tuple_eta", "...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
card_inj_ffuns_on D T (R : pred T) : #|[set f : {ffun D -> T} in ffun_on R | injectiveb f]| = #|R| ^_ #|D|.
Proof. rewrite -card_uniq_tuples. have bijFF: {on (_ : pred _), bijective (@Finfun D T)}. by exists fgraph => x _; [apply: FinfunK | apply: fgraphK]. rewrite -(on_card_preimset (bijFF _)); apply: eq_card => /= t. rewrite !inE -(big_andE predT) -big_image /= big_all. by rewrite -[t in RHS]FinfunK -codom_ffun. Qed.
Lemma
card_inj_ffuns_on
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "Finfun", "FinfunK", "apply", "big_all", "big_andE", "big_image", "card_uniq_tuples", "codom_ffun", "eq_card", "ffun_on", "fgraph", "fgraphK", "inE", "injectiveb", "on", "on_card_preimset" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
card_inj_ffuns D T : #|[set f : {ffun D -> T} | injectiveb f]| = #|T| ^_ #|D|.
Proof. rewrite -card_inj_ffuns_on; apply: eq_card => f. by rewrite 2!inE; case: ffun_onP. Qed.
Lemma
card_inj_ffuns
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "apply", "card_inj_ffuns_on", "eq_card", "ffun_onP", "inE", "injectiveb" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cards_draws T (B : {set T}) k : #|[set A : {set T} | A \subset B & #|A| == k]| = 'C(#|B|, k).
Proof. have [ltTk | lekT] := ltnP #|B| k. rewrite bin_small // eq_card0 // => A. rewrite inE eqn_leq [k <= _]leqNgt. have [AsubB /=|//] := boolP (A \subset B). by rewrite (leq_ltn_trans (subset_leq_card AsubB)) ?andbF. apply/eqP; rewrite -(eqn_pmul2r (fact_gt0 k)) bin_ffact // eq_sym. rewrite -sum_nat_cond_cons...
Lemma
cards_draws
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "apply", "bin_ffact", "bin_small", "card_imset", "card_inj_ffuns", "card_inj_ffuns_on", "card_ord", "enum_rankK_in", "enum_rank_in", "enum_val", "enum_valP", "enum_val_inj", "eqEcard", "eq_bigl", "eq_bigr", "eq_card0", "eq_sym", "eqn_leq", "eqn_pmul2r", "eqxx", "fact_gt0", ...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
card_draws T k : #|[set A : {set T} | #|A| == k]| = 'C(#|T|, k).
Proof. by rewrite -cardsT -cards_draws; apply: eq_card => A; rewrite !inE subsetT. Qed.
Lemma
card_draws
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "apply", "cardsT", "cards_draws", "eq_card", "inE", "subsetT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
card_ltn_sorted_tuples m n : #|[set t : m.-tuple 'I_n | sorted ltn (map val t)]| = 'C(n, m).
Proof. have [-> | n_gt0] := posnP n; last pose i0 := Ordinal n_gt0. case: m => [|m]; last by apply: eq_card0; case/tupleP=> [[]]. by apply: (@eq_card1 _ [tuple]) => t; rewrite [t]tuple0 inE. rewrite -[n in RHS]card_ord -card_draws. pose f_t (t : m.-tuple 'I_n) := [set i in t]. pose f_A (A : {set 'I_n}) := [tuple of...
Lemma
card_ltn_sorted_tuples
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "apply", "cardE", "card_draws", "card_ord", "card_uniqP", "cardsE", "enum", "eq_bigl", "eq_card0", "eq_card1", "eq_filter", "eqxx", "filter_map", "i0", "inE", "inj_eq", "inj_map", "iota_ltn_sorted", "irr_sorted_eq", "last", "ltn", "ltn_trans", "ltnn", "map", "mapP", ...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
card_sorted_tuples m n : #|[set t : m.-tuple 'I_n.+1 | sorted leq (map val t)]| = 'C(m + n, m).
Proof. set In1 := 'I_n.+1; pose x0 : In1 := ord0. have add_mnP (i : 'I_m) (x : In1) : i + x < m + n. by rewrite -ltnS -addSn -!addnS leq_add. pose add_mn t i := Ordinal (add_mnP i (tnth t i)). pose add_mn_nat (t : m.-tuple In1) i := i + nth x0 t i. have add_mnC t: val \o add_mn t =1 add_mn_nat t \o val. by move=> i...
Lemma
card_sorted_tuples
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "add0n", "addKn", "addSn", "addSnnS", "addn1", "addnS", "apply", "card_ltn_sorted_tuples", "drop0", "drop_nth", "drop_oversize", "drop_size", "enumT", "eq_bigl", "eq_from_tnth", "eq_map", "inE", "inord", "inordK", "inord_val", "last", "leq", "leq_add", "leq_add2l", "l...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
card_partial_ord_partitions m n : #|[set t : m.-tuple 'I_n.+1 | \sum_(i <- t) i <= n]| = 'C(m + n, m).
Proof. symmetry; set In1 := 'I_n.+1; pose x0 : In1 := ord0. pose add_mn (i j : In1) : In1 := inord (i + j). pose f_add (t : m.-tuple In1) := [tuple of scanl add_mn x0 t]. rewrite -card_sorted_tuples -!sum1dep_card (reindex f_add) /=; last first. apply: eq_bigl => t; rewrite -[\sum_(i <- t) i]add0n. transitivity (pa...
Lemma
card_partial_ord_partitions
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "add0n", "addKn", "addn0", "addnA", "apply", "big_cons", "big_nil", "card_sorted_tuples", "eq_bigl", "inE", "inord", "inord_val", "last", "leq", "leqNgt", "leqP", "leq_add2r", "leq_addr", "leq_ltn_trans", "leq_subr", "leq_trans", "ltnS", "ltn_ord", "map", "ord0", "p...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
card_ord_partitions m n : #|[set t : m.+1.-tuple 'I_n.+1 | \sum_(i <- t) i == n]| = 'C(m + n, m).
Proof. symmetry; set In1 := 'I_n.+1; pose x0 : In1 := ord0. pose f_add (t : m.-tuple In1) := [tuple of sub_ord (\sum_(x <- t) x) :: t]. rewrite -card_partial_ord_partitions -!sum1dep_card (reindex f_add) /=; last first. by apply: eq_bigl => t; rewrite big_cons /= addnC (sameP maxn_idPr eqP) maxnE. exists (fun t :...
Lemma
card_ord_partitions
boot
boot/binomial.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "div", "fintype", "tuple", "finfun", "bigop", "prime", "finset" ]
[ "addnC", "addnK", "apply", "behead", "big_cons", "card_partial_ord_partitions", "def_n", "eq_bigl", "inE", "last", "maxnE", "maxn_idPr", "ord0", "reindex", "sub_ord", "sum1dep_card", "tuple", "tupleP", "val_inj" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
code
:= foldr (fun n m => 2 ^ n * m.*2.+1) 0.
Definition
code
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "foldr" ]
nk 0s n2 0s n1 0s
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
decode_rec (v q r : nat) {struct q}
:= match q, r with | 0, _ => [:: v] | q'.+1, 0 => v :: [rec 0, q', q'] | q'.+1, 1 => [rec v.+1, q', q'] | q'.+1, r'.+2 => [rec v, q', r'] end where "[ 'rec' v , q , r ]" := (decode_rec v q r).
Fixpoint
decode_rec
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "nat" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
decode n
:= if n is 0 then [::] else [rec 0, n.-1, n.-1].
Definition
decode
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
decodeK : cancel decode code.
Proof. have m2s: forall n, n.*2 - n = n by move=> n; rewrite -addnn addnK. case=> //= n; rewrite -[n.+1]mul1n -(expn0 2) -[n in RHS]m2s. elim: n {2 4}n {1 3}0 => [|q IHq] [|[|r]] v //=; rewrite {}IHq ?mul1n ?m2s //. by rewrite expnSr -mulnA mul2n. Qed.
Lemma
decodeK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "addnK", "addnn", "code", "decode", "expn0", "expnSr", "mul1n", "mul2n", "mulnA" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
codeK : cancel code decode.
Proof. elim=> //= v s IHs; rewrite -[_ * _]prednK ?muln_gt0 ?expn_gt0 //=. set two := 2; rewrite -[v in RHS]addn0; elim: v 0 => [|v IHv {IHs}] q. rewrite mul1n add0n /= -{}[in RHS]IHs; case: (code s) => // u; pose n := u.+1. by transitivity [rec q, n + u.+1, n.*2]; [rewrite addnn | elim: n => //=]. rewrite expnS -m...
Lemma
codeK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "add0n", "addSnnS", "addn0", "addnn", "code", "decode", "expnS", "expn_gt0", "mul1n", "mul2n", "mulnA", "muln_gt0", "prednK" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
ltn_code s : all (fun j => j < code s) s.
Proof. elim: s => //= i s IHs; rewrite -[_.+1]muln1 leq_mul 1?ltn_expl //=. apply: sub_all IHs => j /leqW lejs; rewrite -[j.+1]mul1n leq_mul ?expn_gt0 //. by rewrite ltnS -[j]mul1n -mul2n leq_mul. Qed.
Lemma
ltn_code
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "all", "apply", "code", "expn_gt0", "leqW", "leq_mul", "ltnS", "ltn_expl", "mul1n", "mul2n", "muln1", "sub_all" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
gtn_decode n : all (ltn^~ n) (decode n).
Proof. by rewrite -{1}[n]decodeK ltn_code. Qed.
Lemma
gtn_decode
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "all", "decode", "decodeK", "ltn", "ltn_code" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
seq_of_opt
:= @oapp T _ (nseq 1) [::].
Definition
seq_of_opt
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
seq_of_optK : cancel seq_of_opt ohead.
Proof. by case. Qed.
Lemma
seq_of_optK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "ohead", "seq_of_opt" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tag_of_pair (p : T1 * T2)
:= @Tagged T1 p.1 (fun _ => T2) p.2.
Definition
tag_of_pair
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pair_of_tag (u : {i : T1 & T2})
:= (tag u, tagged u).
Definition
pair_of_tag
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tag_of_pairK : cancel tag_of_pair pair_of_tag.
Proof. by case. Qed.
Lemma
tag_of_pairK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "pair_of_tag", "tag_of_pair" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pair_of_tagK : cancel pair_of_tag tag_of_pair.
Proof. by case. Qed.
Lemma
pair_of_tagK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "pair_of_tag", "tag_of_pair" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
opair_of_sum (s : T1 + T2)
:= match s with inl x => (Some x, None) | inr y => (None, Some y) end.
Definition
opair_of_sum
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sum_of_opair p
:= oapp (some \o @inr T1 T2) (omap (@inl _ T2) p.1) p.2.
Definition
sum_of_opair
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
opair_of_sumK : pcancel opair_of_sum sum_of_opair.
Proof. by case. Qed.
Lemma
opair_of_sumK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "opair_of_sum", "sum_of_opair" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
bool_of_unitK : cancel (fun _ => true) (fun _ => tt).
Proof. by case. Qed.
Lemma
bool_of_unitK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tree
:= Leaf of T | Node of nat & seq tree.
Inductive
tree
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Leaf", "nat", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tree_rect K IH_leaf IH_node
:= fix loop t : K t := match t with | Leaf x => IH_leaf x | Node n f0 => let fix iter_pair f : foldr (fun t => prod (K t)) unit f := if f is t :: f' then (loop t, iter_pair f') else tt in IH_node n f0 (iter_pair f0) end.
Definition
tree_rect
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Leaf", "foldr", "prod", "unit" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tree_rec (K : tree -> Set)
:= @tree_rect K.
Definition
tree_rec
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "tree", "tree_rect" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tree_ind K IH_leaf IH_node
:= fix loop t : K t : Prop := match t with | Leaf x => IH_leaf x | Node n f0 => let fix iter_conj f : foldr (fun t => and (K t)) True f := if f is t :: f' then conj (loop t) (iter_conj f') else Logic.I in IH_node n f0 (iter_conj f0) end.
Definition
tree_ind
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Leaf", "True", "conj", "foldr" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
encode t : seq (nat + T)
:= match t with | Leaf x => [:: inr _ x] | Node n f => inl _ n.+1 :: rcons (flatten (map encode f)) (inl _ 0) end.
Fixpoint
encode
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Leaf", "flatten", "map", "nat", "rcons", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
decode_step c fs
:= match c with | inr x => (Leaf x :: fs.1, fs.2) | inl 0 => ([::], fs.1 :: fs.2) | inl n.+1 => (Node n fs.1 :: head [::] fs.2, behead fs.2) end.
Definition
decode_step
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Leaf", "behead", "head" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
decode c
:= ohead (foldr decode_step ([::], [::]) c).1.
Definition
decode
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "decode_step", "foldr", "ohead" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
codeK : pcancel encode decode.
Proof. move=> t; rewrite /decode; set fs := (_, _). suffices ->: foldr decode_step fs (encode t) = (t :: fs.1, fs.2) by []. elim: t => //= n f IHt in (fs) *; elim: f IHt => //= t f IHf []. by rewrite rcons_cat foldr_cat => -> /= /IHf[-> -> ->]. Qed.
Lemma
codeK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "decode", "decode_step", "encode", "foldr", "foldr_cat", "rcons_cat" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
find
:= find_subdef.
Notation
find
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
correct
:= choice_correct_subdef.
Notation
correct
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
complete
:= choice_complete_subdef.
Notation
complete
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
extensional
:= choice_extensional_subdef.
Notation
extensional
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
xchoose_subproof P exP : {x | find P (ex_minn (@choice_complete_subdef _ P exP)) = Some x}.
Proof. case: (ex_minnP (complete exP)) => n. by case: (find P n) => // x; exists x. Qed.
Fact
xchoose_subproof
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "complete", "exP", "ex_minn", "ex_minnP", "find" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
dc
:= decode.
Notation
dc
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "decode" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
xchoose P exP
:= sval (@xchoose_subproof T P exP).
Definition
xchoose
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "exP", "xchoose_subproof" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
xchooseP P exP : P (@xchoose P exP).
Proof. by rewrite /xchoose; case: (xchoose_subproof exP) => x /= /correct. Qed.
Lemma
xchooseP
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "correct", "exP", "xchoose", "xchoose_subproof" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_xchoose P Q exP exQ : P =1 Q -> @xchoose P exP = @xchoose Q exQ.
Proof. rewrite /xchoose => eqPQ. case: (xchoose_subproof exP) => x; case: (xchoose_subproof exQ) => y /=. case: ex_minnP => n; rewrite -(extensional eqPQ) => Pn minQn. case: ex_minnP => m; rewrite !(extensional eqPQ) => Qm minPm. by case: (eqVneq m n) => [-> -> [] //|]; rewrite eqn_leq minQn ?minPm. Qed.
Lemma
eq_xchoose
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "eqVneq", "eqn_leq", "exP", "ex_minnP", "extensional", "xchoose", "xchoose_subproof" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sigW P : (exists x, P x) -> {x | P x}.
Proof. by move=> exP; exists (xchoose exP); apply: xchooseP. Qed.
Lemma
sigW
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "apply", "exP", "xchoose", "xchooseP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sig2W P Q : (exists2 x, P x & Q x) -> {x | P x & Q x}.
Proof. move=> exPQ; have [|x /andP[]] := @sigW (predI P Q); last by exists x. by have [x Px Qx] := exPQ; exists x; apply/andP. Qed.
Lemma
sig2W
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Px", "apply", "last", "sigW" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sig_eqW (vT : eqType) (lhs rhs : T -> vT) : (exists x, lhs x = rhs x) -> {x | lhs x = rhs x}.
Proof. move=> exP; suffices [x /eqP Ex]: {x | lhs x == rhs x} by exists x. by apply: sigW; have [x /eqP Ex] := exP; exists x. Qed.
Lemma
sig_eqW
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "apply", "exP", "rhs", "sigW", "vT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sig2_eqW (vT : eqType) (P : pred T) (lhs rhs : T -> vT) : (exists2 x, P x & lhs x = rhs x) -> {x | P x & lhs x = rhs x}.
Proof. move=> exP; suffices [x Px /eqP Ex]: {x | P x & lhs x == rhs x} by exists x. by apply: sig2W; have [x Px /eqP Ex] := exP; exists x. Qed.
Lemma
sig2_eqW
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Px", "apply", "exP", "rhs", "sig2W", "vT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sig_eq2W (vT vT' : eqType) (lhs rhs : T -> vT) (lhs' rhs' : T -> vT') : (exists2 x : T, lhs x = rhs x & lhs' x = rhs' x) -> {x : T | lhs x = rhs x & lhs' x = rhs' x}.
Proof. move=> e; suff [x /eqP]: {x : T | lhs x == rhs x & lhs' x = rhs' x} by exists x. by apply: sig2_eqW; case: e => x /eqP; exists x. Qed.
Lemma
sig_eq2W
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "apply", "rhs", "sig2_eqW", "vT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
choose P x0
:= if insub x0 : {? x | P x} is Some (exist x Px) then xchoose (ex_intro [eta P] x Px) else x0.
Definition
choose
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Px", "insub", "xchoose" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
chooseP P x0 : P x0 -> P (choose P x0).
Proof. by move=> Px0; rewrite /choose insubT xchooseP. Qed.
Lemma
chooseP
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "choose", "insubT", "xchooseP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
choose_id P x0 y0 : P x0 -> P y0 -> choose P x0 = choose P y0.
Proof. by move=> Px0 Py0; rewrite /choose !insubT /=; apply: eq_xchoose. Qed.
Lemma
choose_id
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "apply", "choose", "eq_xchoose", "insubT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_choose P Q : P =1 Q -> choose P =1 choose Q.
Proof. rewrite /choose => eqPQ x0. do [case: insubP; rewrite eqPQ] => [[x Px] Qx0 _| ?]; last by rewrite insubN. by rewrite insubT; apply: eq_xchoose. Qed.
Lemma
eq_choose
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Px", "apply", "choose", "eq_xchoose", "insubN", "insubP", "insubT", "last" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
PCanHasChoice f' : pcancel f f' -> hasChoice sT.
Proof. move=> fK; pose liftP sP := [pred x | oapp sP false (f' x)]. pose sf sP := [fun n => obind f' (find (liftP sP) n)]. exists sf => [sP n x | sP [y sPy] | sP sQ eqPQ n] /=. - by case Df: (find _ n) => //= [?] Dx; have:= correct Df; rewrite /= Dx. - have [|n Pn] := @complete T (liftP sP); first by exists (f y); rewr...
Lemma
PCanHasChoice
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Dx", "apply", "complete", "correct", "extensional", "fK", "find", "sT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
CanHasChoice f' (fK : cancel f f')
:= PCanHasChoice (can_pcan fK).
Definition
CanHasChoice
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "PCanHasChoice", "fK" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
seq_hasChoice : hasChoice (seq T).
Proof. pose r f := [fun xs => fun x : T => f (x :: xs) : option (seq T)]. pose fix f sP ns xs {struct ns} := if ns is n :: ns1 then let fr := r (f sP ns1) xs in obind fr (find fr n) else if sP xs then Some xs else None. exists (fun sP nn => f sP (dc nn) nil) => [sP n ys | sP [ys] | sP sQ eqPQ n]. - elim: {n}(dc n) ...
Fact
seq_hasChoice
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "apply", "cat_rcons", "cats0", "code", "codeK", "complete", "correct", "dc", "extensional", "find", "last_ind", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
tagged_hasChoice : hasChoice {i : I & T_ i}.
Proof. pose mkT i (x : T_ i) := Tagged T_ x. pose ft tP n i := omap (mkT i) (find (tP \o mkT i) n). pose fi tP ni nt := obind (ft tP nt) (find (ft tP nt) ni). pose f tP n := if dc n is [:: ni; nt] then fi tP ni nt else None. exists f => [tP n u | tP [[i x] tPxi] | sP sQ eqPQ n]. - rewrite /f /fi; case: (dc n) => [|ni [...
Fact
tagged_hasChoice
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "apply", "code", "codeK", "complete", "correct", "dc", "extensional", "find" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nat_hasChoice : hasChoice nat.
Proof. pose f := [fun (P : pred nat) n => if P n then Some n else None]. exists f => [P n m | P [n Pn] | P Q eqPQ n] /=; last by rewrite eqPQ. by case: ifP => // Pn [<-]. by exists n; rewrite Pn. Qed.
Fact
nat_hasChoice
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "last", "nat" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
"[ 'Choice' 'of' T 'by' <: ]"
:= (Choice.copy T%type (sub_type T%type)) (format "[ 'Choice' 'of' T 'by' <: ]") : form_scope.
Notation
[ 'Choice' 'of' T 'by' <: ]
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "copy", "sub_type", "type" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pickle_inv n
:= obind (fun x : T => if pickle x == n then Some x else None) (unpickle n).
Definition
pickle_inv
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pickle_invK : ocancel pickle_inv pickle.
Proof. by rewrite /pickle_inv => n; case def_x: (unpickle n) => //= [x]; case: eqP. Qed.
Lemma
pickle_invK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "pickle_inv" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pickleK_inv : pcancel pickle pickle_inv.
Proof. by rewrite /pickle_inv => x; rewrite pickleK /= eqxx. Qed.
Lemma
pickleK_inv
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "eqxx", "pickle_inv" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pcan_pickleK sT f f' : @pcancel T sT f f' -> pcancel (pickle \o f) (pcomp f' unpickle).
Proof. by move=> fK x; rewrite /pcomp pickleK /= fK. Qed.
Lemma
pcan_pickleK
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "fK", "sT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
PCanIsCountable sT (f : sT -> T) f' (fK : pcancel f f')
:= isCountable.Build sT (pcan_pickleK fK).
Definition
PCanIsCountable
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "Build", "fK", "isCountable", "pcan_pickleK", "sT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
CanIsCountable sT f f' (fK : cancel f f')
:= @PCanIsCountable sT _ _ (can_pcan fK).
Definition
CanIsCountable
boot
boot/choice.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "Choice.InternalTheory", "CodeSeq" ]
[ "PCanIsCountable", "fK", "sT" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d