-
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(data/nat/digits): add last_digit_ne_zero
#3544
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.
The proof of the final result looks much better now! Thanks for making these changes.
end | ||
|
||
lemma last_digit_ne_zero (b m : ℕ) (hm : m ≠ 0) (p): | ||
(digits b m).last p ≠ 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.
This lemma would be more convenient if you remove the argument p
and explicitly prove it using digits_ne_nil_iff_ne_zero.mpr hm
.
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.
To be honest that was my first approach to use digits_ne_nil_iff_ne_zero.mpr hm
. I really struggled to get nat.strong_induction_on
to work with it, hence I've generalized over the proof. (see the use of revert p
in the proof). There might be a better approach but this is the best I could come up with.
I can mark this as private
and add in a lemma with the proof provided, would that be ok? So change this to private lemma last_digit_ne_zero_aux
and add
lemma last_digit_ne_zero {b m : ℕ} (hm : m ≠ 0) :
(digits b m).last (digits_ne_nil_iff_ne_zero.mpr hm) ≠ 0 :=
last_digit_ne_zero_aux b m hm (digits_ne_nil_iff_ne_zero.mpr hm)
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've done the above. So marked this one as private lemma last_digit_ne_zero_aux
and then added another lemma that fills in the 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.
That works. Another option was to use as first tactic generalize : digits_ne_nil_iff_ne_zero.mpr hm = p,
exact nat.div_pos (le_of_not_lt hnb) dec_trivial } }, | ||
end | ||
|
||
lemma last_digit_ne_zero (b : ℕ) {m : ℕ} (hm : m ≠ 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.
For this, I think m
can be figured out by later hypotheses, but b
can't be. Right?
Although in the only use of this lemma so far, b
could be inferred.
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.
That is correct. It depends a bit on the lemma whether we make the argument b
explicit in this case (most of the time, but not always, b
can be figured out from the statement you're proving at that time).
bors merge |
The proof of `base_pow_length_digits_le` was refactored as suggested by @fpvandoorn in #3498.
Pull request successfully merged into master. Build succeeded: |
last_digit_ne_zero
last_digit_ne_zero
I thoroughly misunderstood why my prior attempts for #3544 weren't working. I've refactored the proof so the `private` lemma is no longer necessary.
The proof of
base_pow_length_digits_le
was refactored as suggested by @fpvandoorn in #3498.