-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
small generalizations and extensions in poly #202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick review
mathcomp/algebra/ssralg.v
Outdated
@@ -1171,6 +1171,9 @@ Proof. by rewrite exprAC sqrrN !expr1n. Qed. | |||
Lemma signrMK n : @involutive R ( *%R ((-1) ^+ n)). | |||
Proof. by move=> x; rewrite mulrA -expr2 sqrr_sign mul1r. Qed. | |||
|
|||
Lemma lastr_eq0 (s : seq R) x : x != 0 -> (last x s == 0) = (last 1 s == 0). | |||
Proof. by elim: s => [|y s ihs] /negPf // ->; rewrite oner_eq0. Qed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case: s is sufficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
@@ -1171,6 +1171,9 @@ Proof. by rewrite exprAC sqrrN !expr1n. Qed. | |||
Lemma signrMK n : @involutive R ( *%R ((-1) ^+ n)). | |||
Proof. by move=> x; rewrite mulrA -expr2 sqrr_sign mul1r. Qed. | |||
|
|||
Lemma lastr_eq0 (s : seq R) x : x != 0 -> (last x s == 0) = (last 1 s == 0). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this statement could be generalized to
Lemma lastr_eq (s : seq R) (x y z : R) : x != z -> y != z -> (last x s == z) = (last y s == z).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure it is desirable, as 1
is canonical for a R : ringType
... However, maybe the theorem you mention has its place in seq.v
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added your last_eq to seq (for an eqType)
mathcomp/algebra/poly.v
Outdated
(p \Po q)`_n = \sum_(i < size p) p`_i * (q ^+ i)`_n. | ||
Proof. | ||
rewrite comp_polyE coef_sum. | ||
by elim/big_ind2: _ => [//|? ? ? ? -> -> //|i]; rewrite coefZ. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why using induction?
by apply: eq_bigr => i _; rewrite coefZ.
mathcomp/algebra/poly.v
Outdated
by rewrite cardT /= size_enum_ord [in RHS]big_tnth. | ||
Qed. | ||
|
||
Lemma size_prod_eq1 (I : finType) (P : pred I) (F : I -> {poly R}) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems reasonable to also add the mul version
Lemma size_mul_eq1 p q :
(size (p * q) == 1%N) = ((size p == 1%N) && (size q == 1%N)).
mathcomp/algebra/poly.v
Outdated
by rewrite cardT /= size_enum_ord [in RHS]big_tnth. | ||
Qed. | ||
|
||
Lemma size_prod_eq1 (I : finType) (P : pred I) (F : I -> {poly R}) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why restrict this to finType and not prove the general statement
Lemma size_prod_eq1
(I : eqType) (s : seq I) (P : pred I) (F : I -> {poly R}) :
(size (\prod_(i <- s | P i) F i) == 1%N) =
(all (fun i => size (F i) == 1%N) [seq x <- s | P x]).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proof for finType
is way easier and not really restrictive (see the proof of size_prod_seq_eq1
) and the phrasing in terms of [forall (i | P i) ...] is slightly more elegant. I'm quite convinced we want to keep size_prod_eq1
as such, but I am less sure about size_prod_seq_eq1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have just one theorem?
mathcomp/algebra/poly.v
Outdated
by elim/big_ind2: _ => // [[] [|n] [] [|m]|i Pi]; rewrite -?polySpred ?F_neq0. | ||
Qed. | ||
|
||
Lemma size_prod_seq_eq1 (I : choiceType) (s : seq I) (F : I -> {poly R}) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be eqType
@@ -4,7 +4,7 @@ Require Import mathcomp.ssreflect.ssreflect. | |||
From mathcomp | |||
Require Import ssrbool ssrfun eqtype ssrnat seq div choice fintype. | |||
From mathcomp | |||
Require Import bigop ssralg binomial. | |||
Require Import bigop ssralg binomial tuple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this new import comes only because you are using big_tnth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
mathcomp/algebra/poly.v
Outdated
Lemma size_mul_eq1 p q : | ||
(size (p * q) == 1%N) = ((size p == 1%N) && (size q == 1%N)). | ||
Proof. | ||
by have := size_prod_seq_eq1 [:: p; q] id; rewrite unlock /= mulr1 andbT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of weird you would expect size_mul_eq1 to help proving the summation theorem not the other way around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but since the proof is not done by induction... (maybe it would be shorter? I did not try)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lemma size_mul_eq1 p q :
(size (p * q) == 1%N) = ((size p == 1%N) && (size q == 1%N)).
Proof.
case: (p =P 0) => [->|/eqP pNZ]; first by rewrite mul0r size_poly0.
case: (q =P 0) => [->|/eqP qNZ]; first by rewrite mulr0 size_poly0 andbF.
rewrite size_mul //.
by move: pNZ qNZ; rewrite -!size_poly_gt0; (do 2 case: size) => //= n [|[|]].
Qed.
Lemma size_prod_seq_eq1 (I : eqType) (s : seq I) (P : pred I) (F : I -> {poly R}) :
(size (\prod_(i <- s | P i) F i) == 1%N) = (all [pred i | P i ==> (size (F i) == 1%N)] s).
Proof.
elim: s => [|a s IH /=]; first by rewrite big_nil size_poly1.
rewrite big_cons; case: (P a) => //=.
by rewrite size_mul_eq1 IH.
Qed.
but maybe size_prod_seq_eq1 should be expressed as a reflect
Added `permutations` and some `perm_eq` lemmas suggested by @MrSet in #299 (except the link to the coq lib `Permutation` predicate). Added support for casts on `map` comprehension general terms. Added `allpairs_map[lr]` suggested by @pi8027 in #314, but with equational proofs; changed `allpairs_comp` to its converse `map_allpairs` for consistency. Documented the `all2` predicate added in #224, and the view combinators added in #202. Renamed `seq2_ind` to `seq_ind2`, and weakened the induction hypothesis, adding a `size` equality assumption. Corrected the header to use `<=>` for `bool` predicate documentation, and `<->` for `Prop` predicates, following the library’s general convention. Replaced the `nosimpl` in `rev` with a `Arguments simpl never` directive, making it possible to merge the `Rev` section into the main `Sequences` section. Miscellaneous improvements to proof scripts and file organisation.
Added `permutations` and some `perm_eq` lemmas suggested by @MrSet in #299 (except the link to the coq lib `Permutation` predicate). Added support for casts on `map` comprehension general terms. Added `allpairs_map[lr]` suggested by @pi8027 in #314, but with equational proofs; changed `allpairs_comp` to its converse `map_allpairs` for consistency. Documented the `all2` predicate added in #224, and the view combinators added in #202. Renamed `seq2_ind` to `seq_ind2`, and weakened the induction hypothesis, adding a `size` equality assumption. Corrected the header to use `<=>` for `bool` predicate documentation, and `<->` for `Prop` predicates, following the library’s general convention. Replaced the `nosimpl` in `rev` with a `Arguments simpl never` directive, making it possible to merge the `Rev` section into the main `Sequences` section. Miscellaneous improvements to proof scripts and file organisation.
Added `permutations` and some `perm_eq` lemmas suggested by @MrSet in #299 (except the link to the coq lib `Permutation` predicate). Added support for casts on `map` comprehension general terms. Added `allpairs_map[lr]` suggested by @pi8027 in #314, but with equational proofs; changed `allpairs_comp` to its converse `map_allpairs` for consistency. Documented the `all2` predicate added in #224, and the view combinators added in #202. Renamed `seq2_ind` to `seq_ind2`, and weakened the induction hypothesis, adding a `size` equality assumption. Corrected the header to use `<=>` for `bool` predicate documentation, and `<->` for `Prop` predicates, following the library’s general convention. Replaced the `nosimpl` in `rev` with a `Arguments simpl never` directive, making it possible to merge the `Rev` section into the main `Sequences` section. Miscellaneous improvements to proof scripts and file organisation.
Added `permutations` and some `perm_eq` lemmas suggested by @MrSet in #299 (except the link to the coq lib `Permutation` predicate). Added support for casts on `map` comprehension general terms. Added `allpairs_map[lr]` suggested by @pi8027 in #314, but with equational proofs; changed `allpairs_comp` to its converse `map_allpairs` for consistency. Documented the `all2` predicate added in #224, and the view combinators added in #202. Renamed `seq2_ind` to `seq_ind2`, and weakened the induction hypothesis, adding a `size` equality assumption. Corrected the header to use `<=>` for `bool` predicate documentation, and `<->` for `Prop` predicates, following the library’s general convention. Replaced the `nosimpl` in `rev` with a `Arguments simpl never` directive, making it possible to merge the `Rev` section into the main `Sequences` section. Miscellaneous improvements to proof scripts and file organisation.
- Added `permutations` and some `perm_eq` lemmas suggested by @MrSet in math-comp#299 (except the link to the coq lib `Permutation` predicate). Use insertion rather than rotation to construct permutations This definition is closer to the one proposed by @MrSet. It adds one line to the definition of `permutations` but the proofs become a little simpler. - Added support for casts on `map` comprehension general terms. - Added `allpairs_map[lr]` suggested by @pi8027 in math-comp#314, but with equational proofs; changed `allpairs_comp` to its converse `map_allpairs` for consistency. Also improves `eq_in_allpairs_dep` proof with @CohenCyril’s proof, and renames `perm_eq_flatten` to `perm_flatten`, consistently with other `perm` lemmas. - Add `allpairs` extensionality lemmas - Added three lemmas, for the non-localised, dependent localised and non-dependent localised cases; as per `eq_in_map`, the latter two are equivalences. - Documented the `all2` predicate added in math-comp#224, and the view combinators added in math-comp#202. - Renamed `seq2_ind` to `seq_ind2`, and weakened the induction hypothesis, adding a `size` equality assumption. - Corrected the header to use `<=>` for `bool` predicate documentation, and `<->` for `Prop` predicates, following the library’s general convention. - Replaced the `nosimpl` in `rev` with a `Arguments simpl never` directive, making it possible to merge the `Rev` section into the main `Sequences` section. - Miscellaneous improvements to proof scripts and file organisation. - correct maximal implicits of `constant` - Fixes omitted `Prenex Implicit` declaration - Other implicits fixes - Fix apparent `done` regression It appears `done` now does a weaker form of intros, and this broke the `dtuple_onP` proof. Updated the proof to eliminate the issue.
- Added `permutations` and some `perm_eq` lemmas suggested by @MrSet in #299 (except the link to the coq lib `Permutation` predicate). Use insertions to construct permutations. This definition is closer to the one proposed by @MrSet, than one using rotations (it adds one line to the definition of `permutations` but the proofs become a little simpler.) - Added support for casts on `map` comprehension general terms. - Added `allpairs_map[lr]` suggested by @pi8027 in #314, but with equational proofs; changed `allpairs_comp` to its converse `map_allpairs` for consistency. - Add three `allpairs` extensionality lemmas: for the non-localised, dependent localised and non-dependent localised cases; as per `eq_in_map`, the latter two are equivalences. - Documented the `all2` predicate added in #224, and the view combinators added in #202. - Renamed `seq2_ind` to `seq_ind2`, and weakened the induction hypothesis, adding a `size` equality assumption. - Corrected the header to use `<=>` for `bool` predicate documentation, and `<->` for `Prop` predicates, following the library’s general convention. - Replaced the `nosimpl` in `rev` with a `Arguments simpl never` directive, making it possible to merge the `Rev` section into the main `Sequences` section. - Miscellaneous improvements to proof scripts and file organisation. - Correct maximal implicits of `constant`. - Fixes omitted `Prenex Implicit` declaration. - Other implicits fixes. - Fix apparent `done` regression It appears `done` now does a weaker form of intros, and this broke the `dtuple_onP` proof. Updated the proof to eliminate the issue. (Commit log edited by @CohenCyril during the squash.)
- Added `permutations` and some `perm_eq` lemmas suggested by @MrSet in #299 (except the link to the coq lib `Permutation` predicate). Use insertions to construct permutations. This definition is closer to the one proposed by @MrSet, than one using rotations (it adds one line to the definition of `permutations` but the proofs become a little simpler.) - Added support for casts on `map` comprehension general terms. - Added `allpairs_map[lr]` suggested by @pi8027 in #314, but with equational proofs; changed `allpairs_comp` to its converse `map_allpairs` for consistency. - Add three `allpairs` extensionality lemmas: for the non-localised, dependent localised and non-dependent localised cases; as per `eq_in_map`, the latter two are equivalences. - Documented the `all2` predicate added in #224, and the view combinators added in #202. - Renamed `seq2_ind` to `seq_ind2`, and weakened the induction hypothesis, adding a `size` equality assumption. - Corrected the header to use `<=>` for `bool` predicate documentation, and `<->` for `Prop` predicates, following the library’s general convention. - Replaced the `nosimpl` in `rev` with a `Arguments simpl never` directive, making it possible to merge the `Rev` section into the main `Sequences` section. - Miscellaneous improvements to proof scripts and file organisation. - Correct maximal implicits of `constant`. - Fixes omitted `Prenex Implicit` declaration. - Other implicits fixes. - Fix apparent `done` regression It appears `done` now does a weaker form of intros, and this broke the `dtuple_onP` proof. Updated the proof to eliminate the issue. (Commit log edited by @CohenCyril during the squash.)
- Added `permutations` and some `perm_eq` lemmas suggested by @MrSet in #299 (except the link to the coq lib `Permutation` predicate). Use insertions to construct permutations. This definition is closer to the one proposed by @MrSet, than one using rotations (it adds one line to the definition of `permutations` but the proofs become a little simpler.) - Added support for casts on `map` comprehension general terms. - Added `allpairs_map[lr]` suggested by @pi8027 in #314, but with equational proofs; changed `allpairs_comp` to its converse `map_allpairs` for consistency. - Add three `allpairs` extensionality lemmas: for the non-localised, dependent localised and non-dependent localised cases; as per `eq_in_map`, the latter two are equivalences. - Documented the `all2` predicate added in #224, and the view combinators added in #202. - Renamed `seq2_ind` to `seq_ind2`, and weakened the induction hypothesis, adding a `size` equality assumption. - Corrected the header to use `<=>` for `bool` predicate documentation, and `<->` for `Prop` predicates, following the library’s general convention. - Replaced the `nosimpl` in `rev` with a `Arguments simpl never` directive, making it possible to merge the `Rev` section into the main `Sequences` section. - Miscellaneous improvements to proof scripts and file organisation. - Correct maximal implicits of `constant`. - Fixes omitted `Prenex Implicit` declaration. - Other implicits fixes. - Fix apparent `done` regression It appears `done` now does a weaker form of intros, and this broke the `dtuple_onP` proof. Updated the proof to eliminate the issue. (Commit log edited by @CohenCyril during the squash.)
- Added `permutations` and some `perm_eq` lemmas suggested by @MrSet in math-comp#299 (except the link to the coq lib `Permutation` predicate). Use insertions to construct permutations. This definition is closer to the one proposed by @MrSet, than one using rotations (it adds one line to the definition of `permutations` but the proofs become a little simpler.) - Added support for casts on `map` comprehension general terms. - Added `allpairs_map[lr]` suggested by @pi8027 in math-comp#314, but with equational proofs; changed `allpairs_comp` to its converse `map_allpairs` for consistency. - Add three `allpairs` extensionality lemmas: for the non-localised, dependent localised and non-dependent localised cases; as per `eq_in_map`, the latter two are equivalences. - Documented the `all2` predicate added in math-comp#224, and the view combinators added in math-comp#202. - Renamed `seq2_ind` to `seq_ind2`, and weakened the induction hypothesis, adding a `size` equality assumption. - Corrected the header to use `<=>` for `bool` predicate documentation, and `<->` for `Prop` predicates, following the library’s general convention. - Replaced the `nosimpl` in `rev` with a `Arguments simpl never` directive, making it possible to merge the `Rev` section into the main `Sequences` section. - Miscellaneous improvements to proof scripts and file organisation. - Correct maximal implicits of `constant`. - Fixes omitted `Prenex Implicit` declaration. - Other implicits fixes. - Fix apparent `done` regression It appears `done` now does a weaker form of intros, and this broke the `dtuple_onP` proof. Updated the proof to eliminate the issue. (Commit log edited by @CohenCyril during the squash.)
No description provided.