Skip to content
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

Merged
merged 5 commits into from
Jul 19, 2018

Conversation

CohenCyril
Copy link
Member

No description provided.

Copy link
Member

@thery thery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick review

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case: s is sufficient

Copy link
Member Author

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).
Copy link
Member

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).

Copy link
Member Author

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

Copy link
Member Author

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)

(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.
Copy link
Member

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.

by rewrite cardT /= size_enum_ord [in RHS]big_tnth.
Qed.

Lemma size_prod_eq1 (I : finType) (P : pred I) (F : I -> {poly R}) :
Copy link
Member

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)).

by rewrite cardT /= size_enum_ord [in RHS]big_tnth.
Qed.

Lemma size_prod_eq1 (I : finType) (P : pred I) (F : I -> {poly R}) :
Copy link
Member

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]).

Copy link
Member Author

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

Copy link
Member

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?

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}) :
Copy link
Member

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.
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

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.
Copy link
Member

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.

Copy link
Member Author

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)

Copy link
Member

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

@thery thery merged commit 1897c99 into math-comp:master Jul 19, 2018
@maximedenes maximedenes added this to the 1.8.0 milestone Mar 22, 2019
ggonthier added a commit that referenced this pull request Apr 4, 2019
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.
ggonthier added a commit that referenced this pull request Apr 4, 2019
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.
ggonthier added a commit that referenced this pull request Apr 4, 2019
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.
ggonthier added a commit that referenced this pull request Apr 4, 2019
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.
CohenCyril pushed a commit to CohenCyril/math-comp that referenced this pull request Apr 4, 2019
- 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.
CohenCyril pushed a commit that referenced this pull request Apr 4, 2019
- 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.)
CohenCyril pushed a commit that referenced this pull request Apr 4, 2019
- 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.)
CohenCyril pushed a commit that referenced this pull request Apr 8, 2019
- 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.)
@CohenCyril CohenCyril deleted the improving-poly branch May 24, 2019 12:04
thery pushed a commit to thery/math-comp that referenced this pull request Jul 10, 2019
- 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.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants