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
pnat_1 pi n : pi.-nat n -> pi^'.-nat n -> n = 1.
Proof. by move=> pi_n pi'_n; rewrite -(eqnP (pnat_coprime pi_n pi'_n)) gcdnn. Qed.
Lemma
pnat_1
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "eqnP", "gcdnn", "nat", "pi", "pnat_coprime" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
part_pnat_id pi n : pi.-nat n -> n`_pi = n.
Proof. case/andP=> n_gt0 pi_n; rewrite -[RHS]partnT // /partn big_mkcond /=. apply: eq_bigr=> p _; have [->|] := posnP (logn p n); first by rewrite if_same. by rewrite logn_gt0 => /(allP pi_n)/= ->. Qed.
Lemma
part_pnat_id
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "allP", "apply", "big_mkcond", "eq_bigr", "logn", "logn_gt0", "n_gt0", "nat", "partn", "partnT", "pi", "posnP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
part_p'nat pi n : pi^'.-nat n -> n`_pi = 1.
Proof. case/andP=> n_gt0 pi'_n; apply: big1_seq => p /andP[pi_p _]. by have [-> //|] := posnP (logn p n); rewrite logn_gt0; case/(allP pi'_n)/negP. Qed.
Lemma
part_p'nat
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "allP", "apply", "big1_seq", "logn", "logn_gt0", "n_gt0", "nat", "pi", "pi_p", "posnP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
partn_eq1 pi n : n > 0 -> (n`_pi == 1) = pi^'.-nat n.
Proof. move=> n_gt0; apply/eqP/idP=> [pi_n_1|]; last exact: part_p'nat. by rewrite -(partnC pi n_gt0) pi_n_1 mul1n part_pnat. Qed.
Lemma
partn_eq1
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "apply", "last", "mul1n", "n_gt0", "nat", "part_p'nat", "part_pnat", "partnC", "pi" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pnatP pi n : n > 0 -> reflect (forall p, prime p -> p %| n -> p \in pi) (pi.-nat n).
Proof. move=> n_gt0; rewrite /pnat n_gt0. apply: (iffP allP) => /= pi_n p => [pr_p p_n|]. by rewrite pi_n // mem_primes pr_p n_gt0. by rewrite mem_primes n_gt0 /=; case/andP; move: p. Qed.
Lemma
pnatP
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "allP", "apply", "mem_primes", "n_gt0", "nat", "pi", "pnat", "pr_p", "prime" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pi_pnat pi p n : p.-nat n -> p \in pi -> pi.-nat n.
Proof. move=> p_n pi_p; have [n_gt0 _] := andP p_n. by apply/pnatP=> // q q_pr /(pnatP _ n_gt0 p_n _ q_pr)/eqnP->. Qed.
Lemma
pi_pnat
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "apply", "eqnP", "n_gt0", "nat", "pi", "pi_p", "pnatP" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
p_natP p n : p.-nat n -> {k | n = p ^ k}.
Proof. by move=> p_n; exists (logn p n); rewrite -p_part part_pnat_id. Qed.
Lemma
p_natP
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "logn", "nat", "p_part", "part_pnat_id" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pi'_p'nat pi p n : pi^'.-nat n -> p \in pi -> p^'.-nat n.
Proof. by move=> pi'n pi_p; apply: sub_in_pnat pi'n => q _; apply: contraNneq => ->. Qed.
Lemma
pi'_p'nat
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "apply", "contraNneq", "nat", "pi", "pi_p", "sub_in_pnat" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
pi_p'nat p pi n : pi.-nat n -> p \in pi^' -> p^'.-nat n.
Proof. by move=> pi_n; apply: pi'_p'nat; rewrite pnatNK. Qed.
Lemma
pi_p'nat
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "apply", "nat", "pi", "pi'_p'nat", "pnatNK" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
partn_part pi rho n : {subset pi <= rho} -> n`_rho`_pi = n`_pi.
Proof. move=> pi_sub_rho; have [->|n_gt0] := posnP n; first by rewrite !partn0 partn1. rewrite -[in RHS](partnC rho n_gt0) partnM //. suffices: pi^'.-nat n`_rho^' by move/part_p'nat->; rewrite muln1. by apply: sub_in_pnat (part_pnat _ _) => q _; apply/contra/pi_sub_rho. Qed.
Lemma
partn_part
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "apply", "muln1", "n_gt0", "nat", "part_p'nat", "part_pnat", "partn0", "partn1", "partnC", "partnM", "pi", "posnP", "sub_in_pnat" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
partnI pi rho n : n`_[predI pi & rho] = n`_pi`_rho.
Proof. rewrite -(@partnC [predI pi & rho] _`_rho) //. symmetry; rewrite 2?partn_part; try by move=> p /andP []. rewrite mulnC part_p'nat ?mul1n // pnatNK pnatI part_pnat andbT. exact: pnat_dvd (dvdn_part _ _) (part_pnat _ _). Qed.
Lemma
partnI
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "dvdn_part", "mul1n", "mulnC", "part_p'nat", "part_pnat", "partnC", "partn_part", "pi", "pnatI", "pnatNK", "pnat_dvd" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
odd_2'nat n : odd n = 2^'.-nat n.
Proof. by case: n => // n; rewrite p'natE // dvdn2 negbK. Qed.
Lemma
odd_2'nat
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "dvdn2", "nat", "odd", "p'natE" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
divisors_correct n : n > 0 -> [/\ uniq (divisors n), sorted leq (divisors n) & forall d, (d \in divisors n) = (d %| n)].
Proof. move/prod_prime_decomp=> def_n; rewrite {4}def_n {def_n}. have: all prime (primes n) by apply/allP=> p; rewrite mem_primes; case/andP. have:= primes_uniq n; rewrite /primes /divisors; move/prime_decomp: n. elim=> [|[p e] pd] /=; first by split=> // d; rewrite big_nil dvdn1 mem_seq1. rewrite big_cons /=; move: (f...
Lemma
divisors_correct
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "Euclid_dvdM", "Gauss_dvdr", "all", "allP", "apply", "big_cons", "big_ind", "big_nil", "big_seq", "cat_uniq", "coprimeXl", "coprime_sym", "def_n", "divisors", "dvdn1", "dvdnP", "dvdn_mulr", "dvdn_pmul2l", "dvdn_prime2", "eqn_pmul2l", "expnS", "foldr", "hasP", "has_pred0...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sorted_divisors n : sorted leq (divisors n).
Proof. by case: (posnP n) => [-> | /divisors_correct[]]. Qed.
Lemma
sorted_divisors
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "divisors", "divisors_correct", "leq", "posnP", "sorted" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
divisors_uniq n : uniq (divisors n).
Proof. by case: (posnP n) => [-> | /divisors_correct[]]. Qed.
Lemma
divisors_uniq
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "divisors", "divisors_correct", "posnP", "uniq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
sorted_divisors_ltn n : sorted ltn (divisors n).
Proof. by rewrite ltn_sorted_uniq_leq divisors_uniq sorted_divisors. Qed.
Lemma
sorted_divisors_ltn
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "divisors", "divisors_uniq", "ltn", "ltn_sorted_uniq_leq", "sorted", "sorted_divisors" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
dvdn_divisors d m : 0 < m -> (d %| m) = (d \in divisors m).
Proof. by case/divisors_correct. Qed.
Lemma
dvdn_divisors
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "divisors", "divisors_correct" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
divisor1 n : 1 \in divisors n.
Proof. by case: n => // n; rewrite -dvdn_divisors // dvd1n. Qed.
Lemma
divisor1
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "divisors", "dvd1n", "dvdn_divisors" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
divisors_id n : 0 < n -> n \in divisors n.
Proof. by move/dvdn_divisors <-. Qed.
Lemma
divisors_id
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "divisors", "dvdn_divisors" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
dvdn_sum d I r (K : pred I) F : (forall i, K i -> d %| F i) -> d %| \sum_(i <- r | K i) F i.
Proof. by move=> dF; elim/big_ind: _ => //; apply: dvdn_add. Qed.
Lemma
dvdn_sum
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "apply", "big_ind", "dvdn_add" ]
Big sum / product lemmas
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
dvdn_partP n m : 0 < n -> reflect (forall p, p \in \pi(n) -> n`_p %| m) (n %| m).
Proof. move=> n_gt0; apply: (iffP idP) => n_dvd_m => [p _|]. by apply: dvdn_trans n_dvd_m; apply: dvdn_part. have [-> // | m_gt0] := posnP m. rewrite -(partnT n_gt0) -(partnT m_gt0). rewrite !(@widen_partn (m + n)) ?leq_addl ?leq_addr // /in_mem /=. elim/big_ind2: _ => // [* | q _]; first exact: dvdn_mul. have [-> //...
Lemma
dvdn_partP
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "apply", "big_ind2", "dvdn_mul", "dvdn_part", "dvdn_trans", "leq_addl", "leq_addr", "logn", "logn_gt0", "mem_primes", "n_gt0", "p_part", "partnT", "pfactorK", "pfactor_dvdn", "pi", "posnP", "prime", "widen_partn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
modn_partP n a b : 0 < n -> reflect (forall p : nat, p \in \pi(n) -> a = b %[mod n`_p]) (a == b %[mod n]).
Proof. move=> n_gt0; wlog le_b_a: a b / b <= a. move=> IH; case: (leqP b a) => [|/ltnW] /IH {IH}// IH. by rewrite eq_sym; apply: (iffP IH) => eqab p /eqab. rewrite eqn_mod_dvd //; apply: (iffP (dvdn_partP _ n_gt0)) => eqab p /eqab; by rewrite -eqn_mod_dvd // => /eqP. Qed.
Lemma
modn_partP
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "apply", "dvdn_partP", "eq_sym", "eqn_mod_dvd", "leqP", "ltnW", "n_gt0", "nat", "pi" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
totientE n : n > 0 -> totient n = \prod_(p <- primes n) (p.-1 * p ^ (logn p n).-1).
Proof. move=> n_gt0; rewrite /totient n_gt0 prime_decompE unlock. by elim: (primes n) => //= [p pr ->]; rewrite !natTrecE. Qed.
Lemma
totientE
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "logn", "n_gt0", "natTrecE", "prime_decompE", "primes", "totient" ]
The Euler totient function
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
totient_gt0 n : (0 < totient n) = (0 < n).
Proof. case: n => // n; rewrite totientE // big_seq_cond prodn_cond_gt0 // => p. by rewrite mem_primes muln_gt0 expn_gt0; case: p => [|[|]]. Qed.
Lemma
totient_gt0
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "big_seq_cond", "expn_gt0", "mem_primes", "muln_gt0", "prodn_cond_gt0", "totient", "totientE" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
totient_pfactor p e : prime p -> e > 0 -> totient (p ^ e) = p.-1 * p ^ e.-1.
Proof. move=> p_pr e_gt0; rewrite totientE ?expn_gt0 ?prime_gt0 //. by rewrite primesX // primes_prime // unlock /= muln1 pfactorK. Qed.
Lemma
totient_pfactor
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "expn_gt0", "muln1", "p_pr", "pfactorK", "prime", "prime_gt0", "primesX", "primes_prime", "totient", "totientE" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
totient_prime p : prime p -> totient p = p.-1.
Proof. by move=> p_prime; rewrite -{1}[p]expn1 totient_pfactor // muln1. Qed.
Lemma
totient_prime
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "expn1", "muln1", "prime", "totient", "totient_pfactor" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
totient_coprime m n : coprime m n -> totient (m * n) = totient m * totient n.
Proof. move=> co_mn; have [-> //| m_gt0] := posnP m. have [->|n_gt0] := posnP n; first by rewrite !muln0. rewrite !totientE ?muln_gt0 ?m_gt0 //. have /(perm_big _)->: perm_eq (primes (m * n)) (primes m ++ primes n). apply: uniq_perm => [||p]; first exact: primes_uniq. by rewrite cat_uniq !primes_uniq -coprime_has...
Lemma
totient_coprime
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "apply", "big_cat", "big_seq", "cat_uniq", "coprime", "coprimeMl", "coprime_has_primes", "coprime_sym", "divnK", "eq_bigr", "logn_Gauss", "mem_cat", "mem_primes", "muln0", "mulnC", "muln_gt0", "n_gt0", "perm_big", "perm_eq", "posnP", "primes", "primesM", "primes_uniq", ...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
totient_count_coprime n : totient n = \sum_(0 <= d < n) coprime n d.
Proof. elim/ltn_ind: n => // n IHn. case: (leqP n 1) => [|lt1n]; first by rewrite unlock; case: (n) => [|[]]. pose p := pdiv n; have p_pr: prime p by apply: pdiv_prime. have p1 := prime_gt1 p_pr; have p0 := ltnW p1. pose np := n`_p; pose np' := n`_p^'. have co_npp': coprime np np' by rewrite coprime_partC. have [n0 np0...
Lemma
totient_count_coprime
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "addnI", "apply", "big_mkcond", "big_mkord", "cardC", "card_in_image", "card_ord", "chinese", "chinese_mod", "chinese_modl", "chinese_modr", "codom", "codomP", "coprime", "coprimeMl", "coprime_modr", "coprime_partC", "coprime_pexpl", "def_n", "dvdnP", "dvdn_mulr", "dvdn_par...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
totient_gt1 n : (totient n > 1) = (n > 2).
Proof. case: n => [|[|[|[|n']]]]//=; set n := n'.+4; rewrite [RHS]isT. wlog [q] : / exists k, k.+3 \in primes n; last first. rewrite mem_primes => /and3P[qp ngt0 qn]. have [[|k]// cqk ->] := pfactor_coprime qp ngt0. rewrite totient_coprime 1?coprime_sym ?coprimeXl//. rewrite totient_pfactor// -?pfactor_dvdn// m...
Lemma
totient_gt1
boot
boot/prime.v
[ "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat", "seq", "path", "choice", "fintype", "div", "bigop", "NatTrec" ]
[ "all_prime_primes", "apply", "big_map", "big_nil", "big_seq1", "coprimeXl", "coprime_sym", "eqxx", "expn_gt0", "in_cons", "last", "leq_pexp2l", "leq_pmulr", "leq_trans", "logn", "mem_head", "mem_primes", "mul1n", "mulnCA", "muln_gt0", "n'", "pfactor_coprime", "pfactor_dvd...
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
seq
:= list.
Notation
seq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
Inductive seq (T : Type) : Type := Nil | Cons of T & seq T.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
Cons T
:= (@cons T) (only parsing).
Notation
Cons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
Nil T
:= (@nil T) (only parsing).
Notation
Nil
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
"[ :: ]"
:= nil (format "[ :: ]") : seq_scope.
Notation
[ :: ]
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
"[ :: x1 ]"
:= (x1 :: [::]) (format "[ :: x1 ]") : seq_scope.
Notation
[ :: x1 ]
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
"[ :: x & s ]"
:= (x :: s) (only parsing) : seq_scope.
Notation
[ :: x & s ]
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
"[ :: x1 , x2 , .. , xn & s ]"
:= (x1 :: x2 :: .. (xn :: s) ..) (format "'[hv' [ :: '[' x1 , '/' x2 , '/' .. , '/' xn ']' '/ ' & s ] ']'" ) : seq_scope.
Notation
[ :: x1 , x2 , .. , xn & s ]
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
"[ :: x1 ; x2 ; .. ; xn ]"
:= (x1 :: x2 :: .. [:: xn] ..) (format "[ :: '[' x1 ; '/' x2 ; '/' .. ; '/' xn ']' ]" ) : seq_scope.
Notation
[ :: x1 ; x2 ; .. ; xn ]
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size s
:= if s is _ :: s' then (size s').+1 else 0.
Fixpoint
size
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size0nil s : size s = 0 -> s = [::].
Proof. by case: s. Qed.
Lemma
size0nil
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nilp s
:= size s == 0.
Definition
nilp
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nilP s : reflect (s = [::]) (nilp s).
Proof. by case: s => [|x s]; constructor. Qed.
Lemma
nilP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nilp" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
ohead s
:= if s is x :: _ then Some x else None.
Definition
ohead
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
head s
:= if s is x :: _ then x else x0.
Definition
head
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
behead s
:= if s is _ :: s' then s' else [::].
Definition
behead
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_behead s : size (behead s) = (size s).-1.
Proof. by case: s. Qed.
Lemma
size_behead
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "behead", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
ncons n x
:= iter n (cons x).
Definition
ncons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "iter" ]
Factories
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nseq n x
:= ncons n x [::].
Definition
nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "ncons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_ncons n x s : size (ncons n x s) = n + size s.
Proof. by elim: n => //= n ->. Qed.
Lemma
size_ncons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "ncons", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_nseq n x : size (nseq n x) = n.
Proof. by rewrite size_ncons addn0. Qed.
Lemma
size_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn0", "nseq", "size", "size_ncons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
seqn_type n
:= if n is n'.+1 then T -> seqn_type n' else seq T.
Fixpoint
seqn_type
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "n'", "seq" ]
n-ary, dependently typed constructor.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
seqn_rec f n : seqn_type n
:= if n is n'.+1 return seqn_type n then fun x => seqn_rec (fun s => f (x :: s)) n' else f [::].
Fixpoint
seqn_rec
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "n'", "seqn_type" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
seqn
:= seqn_rec id.
Definition
seqn
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "id", "seqn_rec" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cat s1 s2
:= if s1 is x :: s1' then x :: s1' ++ s2 else s2 where "s1 ++ s2" := (cat s1 s2) : seq_scope.
Fixpoint
cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "s1", "s2" ]
Sequence catenation "cat".
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cat0s s : [::] ++ s = s.
Proof. by []. Qed.
Lemma
cat0s
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cat1s x s : [:: x] ++ s = x :: s.
Proof. by []. Qed.
Lemma
cat1s
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cat_cons x s1 s2 : (x :: s1) ++ s2 = x :: s1 ++ s2.
Proof. by []. Qed.
Lemma
cat_cons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cat_nseq n x s : nseq n x ++ s = ncons n x s.
Proof. by elim: n => //= n ->. Qed.
Lemma
cat_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "ncons", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nseqD n1 n2 x : nseq (n1 + n2) x = nseq n1 x ++ nseq n2 x.
Proof. by rewrite cat_nseq /nseq /ncons iterD. Qed.
Lemma
nseqD
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cat_nseq", "iterD", "ncons", "nseq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cats0 s : s ++ [::] = s.
Proof. by elim: s => //= x s ->. Qed.
Lemma
cats0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
catA s1 s2 s3 : s1 ++ s2 ++ s3 = (s1 ++ s2) ++ s3.
Proof. by elim: s1 => //= x s1 ->. Qed.
Lemma
catA
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "s1", "s2", "s3" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_cat s1 s2 : size (s1 ++ s2) = size s1 + size s2.
Proof. by elim: s1 => //= x s1 ->. Qed.
Lemma
size_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "s1", "s2", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cat_nilp s1 s2 : nilp (s1 ++ s2) = nilp s1 && nilp s2.
Proof. by case: s1. Qed.
Lemma
cat_nilp
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nilp", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rcons s z
:= if s is x :: s' then x :: rcons s' z else [:: z].
Fixpoint
rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
last, belast, rcons, and last induction.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rcons_cons x s z : rcons (x :: s) z = x :: rcons s z.
Proof. by []. Qed.
Lemma
rcons_cons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cats1 s z : s ++ [:: z] = rcons s z.
Proof. by elim: s => //= x s ->. Qed.
Lemma
cats1
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
last x s
:= if s is x' :: s' then last x' s' else x.
Fixpoint
last
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
belast x s
:= if s is x' :: s' then x :: (belast x' s') else [::].
Fixpoint
belast
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
lastI x s : x :: s = rcons (belast x s) (last x s).
Proof. by elim: s x => [|y s IHs] x //=; rewrite IHs. Qed.
Lemma
lastI
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "belast", "last", "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
last_cons x y s : last x (y :: s) = last y s.
Proof. by []. Qed.
Lemma
last_cons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "last" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_rcons s x : size (rcons s x) = (size s).+1.
Proof. by rewrite -cats1 size_cat addnC. Qed.
Lemma
size_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addnC", "cats1", "rcons", "size", "size_cat" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_belast x s : size (belast x s) = size s.
Proof. by elim: s x => [|y s IHs] x //=; rewrite IHs. Qed.
Lemma
size_belast
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "belast", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
last_cat x s1 s2 : last x (s1 ++ s2) = last (last x s1) s2.
Proof. by elim: s1 x => [|y s1 IHs] x //=; rewrite IHs. Qed.
Lemma
last_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "last", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
last_rcons x s z : last x (rcons s z) = z.
Proof. by rewrite -cats1 last_cat. Qed.
Lemma
last_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "cats1", "last", "last_cat", "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
belast_cat x s1 s2 : belast x (s1 ++ s2) = belast x s1 ++ belast (last x s1) s2.
Proof. by elim: s1 x => [|y s1 IHs] x //=; rewrite IHs. Qed.
Lemma
belast_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "belast", "last", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
belast_rcons x s z : belast x (rcons s z) = x :: s.
Proof. by rewrite lastI -!cats1 belast_cat. Qed.
Lemma
belast_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "belast", "belast_cat", "cats1", "lastI", "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
cat_rcons x s1 s2 : rcons s1 x ++ s2 = s1 ++ x :: s2.
Proof. by rewrite -cats1 -catA. Qed.
Lemma
cat_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "catA", "cats1", "rcons", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
rcons_cat x s1 s2 : rcons (s1 ++ s2) x = s1 ++ rcons s2 x.
Proof. by rewrite -!cats1 catA. Qed.
Lemma
rcons_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "catA", "cats1", "rcons", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
last_spec : seq T -> Type
:= | LastNil : last_spec [::] | LastRcons s x : last_spec (rcons s x).
Variant
last_spec
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "rcons", "seq" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
lastP s : last_spec s.
Proof. case: s => [|x s]; [left | rewrite lastI; right]. Qed.
Lemma
lastP
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "lastI", "last_spec" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
last_ind P : P [::] -> (forall s x, P s -> P (rcons s x)) -> forall s, P s.
Proof. move=> Hnil Hlast s; rewrite -(cat0s s). elim: s [::] Hnil => [|x s2 IHs] s1 Hs1; first by rewrite cats0. by rewrite -cat_rcons; apply/IHs/Hlast. Qed.
Lemma
last_ind
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "cat0s", "cat_rcons", "cats0", "rcons", "s1", "s2" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth s n {struct n}
:= if s is x :: s' then if n is n'.+1 then @nth s' n' else x else x0.
Fixpoint
nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "n'" ]
Sequence indexing.
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
set_nth s n y {struct n}
:= if s is x :: s' then if n is n'.+1 then x :: @set_nth s' n' y else y :: s' else ncons n x0 [:: y].
Fixpoint
set_nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "n'", "ncons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth0 s : nth s 0 = head s.
Proof. by []. Qed.
Lemma
nth0
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "head", "nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_default s n : size s <= n -> nth s n = x0.
Proof. by elim: s n => [|x s IHs] []. Qed.
Lemma
nth_default
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nth", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
if_nth s b n : b || (size s <= n) -> (if b then nth s n else x0) = nth s n.
Proof. by case: leqP; case: ifP => //= *; rewrite nth_default. Qed.
Lemma
if_nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "leqP", "nth", "nth_default", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_nil n : nth [::] n = x0.
Proof. by case: n. Qed.
Lemma
nth_nil
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_seq1 n x : nth [:: x] n = if n == 0 then x else x0.
Proof. by case: n => [|[]]. Qed.
Lemma
nth_seq1
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
last_nth x s : last x s = nth (x :: s) (size s).
Proof. by elim: s x => [|y s IHs] x /=. Qed.
Lemma
last_nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "last", "nth", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_last s : nth s (size s).-1 = last x0 s.
Proof. by case: s => //= x s; rewrite last_nth. Qed.
Lemma
nth_last
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "last", "last_nth", "nth", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_behead s n : nth (behead s) n = nth s n.+1.
Proof. by case: s n => [|x s] [|n]. Qed.
Lemma
nth_behead
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "behead", "nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_cat s1 s2 n : nth (s1 ++ s2) n = if n < size s1 then nth s1 n else nth s2 (n - size s1).
Proof. by elim: s1 n => [|x s1 IHs] []. Qed.
Lemma
nth_cat
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nth", "s1", "s2", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_cons x s n : nth (x :: s) n = if n > 0 then nth s n.-1 else x.
Proof. by case: n. Qed.
Lemma
nth_cons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_rcons s x n : nth (rcons s x) n = if n < size s then nth s n else if n == size s then x else x0.
Proof. by elim: s n => [|y s IHs] [] //=; apply: nth_nil. Qed.
Lemma
nth_rcons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "nth", "nth_nil", "rcons", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_rcons_default s i : nth (rcons s x0) i = nth s i.
Proof. by rewrite nth_rcons; case: ltngtP => //[/ltnW ?|->]; rewrite nth_default. Qed.
Lemma
nth_rcons_default
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "ltnW", "ltngtP", "nth", "nth_default", "nth_rcons", "rcons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_ncons m x s n : nth (ncons m x s) n = if n < m then x else nth s (n - m).
Proof. by elim: m n => [|m IHm] []. Qed.
Lemma
nth_ncons
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "ncons", "nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_nseq m x n : nth (nseq m x) n = (if n < m then x else x0).
Proof. by elim: m n => [|m IHm] []. Qed.
Lemma
nth_nseq
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "nseq", "nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
eq_from_nth s1 s2 : size s1 = size s2 -> (forall i, i < size s1 -> nth s1 i = nth s2 i) -> s1 = s2.
Proof. elim: s1 s2 => [|x1 s1 IHs1] [|x2 s2] //= [eq_sz] eq_s12. by rewrite [x1](eq_s12 0) // (IHs1 s2) // => i; apply: (eq_s12 i.+1). Qed.
Lemma
eq_from_nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "apply", "nth", "s1", "s2", "size" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
size_set_nth s n y : size (set_nth s n y) = maxn n.+1 (size s).
Proof. rewrite maxnC; elim: s n => [|x s IHs] [|n] //=. - by rewrite size_ncons addn1. - by rewrite IHs maxnSS. Qed.
Lemma
size_set_nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "addn1", "maxn", "maxnC", "maxnSS", "set_nth", "size", "size_ncons" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
set_nth_nil n y : set_nth [::] n y = ncons n x0 [:: y].
Proof. by case: n. Qed.
Lemma
set_nth_nil
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "ncons", "set_nth" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d
nth_set_nth s n y : nth (set_nth s n y) =1 [eta nth s with n |-> y].
Proof. elim: s n => [|x s IHs] [|n] [|m] //=; rewrite ?nth_nil ?IHs // nth_ncons eqSS. case: ltngtP => // [lt_nm | ->]; last by rewrite subnn. by rewrite nth_default // subn_gt0. Qed.
Lemma
nth_set_nth
boot
boot/seq.v
[ "HB", "structures", "mathcomp", "ssreflect", "ssrfun", "ssrbool", "eqtype", "ssrnat" ]
[ "eqSS", "last", "ltngtP", "nth", "nth_default", "nth_ncons", "nth_nil", "set_nth", "subn_gt0", "subnn" ]
https://github.com/math-comp/math-comp
91d97df9cf3204b4dab84f4e24bc633e84b6473d