-
Notifications
You must be signed in to change notification settings - Fork 297
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
[Merged by Bors] - feat(algebra/big_operators/basic): add lemma finset.prod_dvd_prod
#11521
Conversation
lemma prod_dvd {S : finset α} (g1 g2 : α → β) (h : ∀ a ∈ S, g1 a ∣ g2 a) : S.prod g1 ∣ S.prod g2 := | ||
begin | ||
classical, | ||
apply finset.induction_on' S, { simp }, |
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.
apply finset.induction_on' S, { simp }, | |
induction S using finset.induction_on' with a T haS _ haT IH, | |
{ simp }, |
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.
Although I think you might not need the primed version here based on the _
in your intros below.
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 can get this to work with the unprimed version, although the proof then becomes a bit longer:
lemma prod_dvd_prod {S : finset α} (g1 g2 : α → β) (h : ∀ a ∈ S, g1 a ∣ g2 a) :
S.prod g1 ∣ S.prod g2 :=
begin
classical,
induction S using finset.induction_on with a T haT h1, { simp },
repeat {rw finset.prod_insert haT},
apply mul_dvd_mul,
{ apply h, simp },
{ refine h1 (λ x hx, _), simp [h, mem_insert_of_mem hx] },
end
However, if I try using the primed version as you first suggested I immediately and consistently get Server has stopped due to signal SIGSEGV
as soon as the compiler hits that line. Any idea what's going wrong here, or should I just ask on Zulip?
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.
If you reliably get a sigsegv, then I'd push the broken version and ask on zulip what's going on.
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.
Hmm, just as mysteriously I'm no longer getting the SIGSEGV
at all and I can't reproduce it.
Now induction S using finset.induction_on'
just gives induction tactic failed, failed to create new goal
(which is also strange, given that apply finset.induction_on' S
does work).
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.
Well, the style guide wants
apply finset.induction_on' S, { simp }, | |
apply finset.induction_on' S, | |
{ simp }, |
Which means my spelling is fewer lines that the version matching the style
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.
Really? I understood the style guide to say that it's ok to immediately close a trivial goal on the same line, and it explicitly gives the example of induction n, { simp }
. A quick search turns up lots of examples of induction ..., { simp...
on a single line (and several with apply
or refine
).
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.
And although your version is fewer lines, I can't find a way to get it to work in fewer characters since, as I noted above, induction S using finset.induction_on'
doesn't seem to work for some reason, while induction S using finset.induction_on
produces a longer proof.
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 think we've always taken a pretty pragmatic approach to that aspect of the style guide.
Arguable the induction .. with ..
shares more semantic information than the generic apply
. But I wouldn't get hung up over this.
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.
Ok, thanks. So is the proof ok as it stands (in this respect, at least)?
finset.prod_dvd
finset.prod_dvd_prod
LGTM! bors merge |
…11521) For any `S : finset α`, if `∀ a ∈ S, g1 a ∣ g2 a` then `S.prod g1 ∣ S.prod g2`.
Pull request successfully merged into master. Build succeeded: |
finset.prod_dvd_prod
finset.prod_dvd_prod
For any
S : finset α
, if∀ a ∈ S, g1 a ∣ g2 a
thenS.prod g1 ∣ S.prod g2
.