Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

feat(data/nat/digits): Add lemmas#7813

Open
Pazzaz wants to merge 7 commits into
masterfrom
digits_prefix
Open

feat(data/nat/digits): Add lemmas#7813
Pazzaz wants to merge 7 commits into
masterfrom
digits_prefix

Conversation

@Pazzaz
Copy link
Copy Markdown
Collaborator

@Pazzaz Pazzaz commented Jun 3, 2021

Add some lemmas about nat.digits and nat.of_digits, including that digits b (of_digits b L) is a prefix of L


I found the need for these lemmas while formalizing properties of Kaprekar's routine.

(Note: this is my first PR 🙂)

Open in Gitpod

Comment thread src/data/nat/digits.lean Outdated
Comment thread src/data/nat/digits.lean Outdated
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

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

This looks good to me now, thanks. I'll leave it a day or two in case another reviewer has suggestions for shortening the proof

@eric-wieser eric-wieser added the awaiting-review The author would like community review of the PR label Jun 4, 2021
Copy link
Copy Markdown
Collaborator

@ericrbg ericrbg left a comment

Choose a reason for hiding this comment

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

this looks really good! fantastic first PR

Comment thread src/data/nat/digits.lean Outdated
Comment thread src/data/nat/digits.lean Outdated
Comment thread src/data/nat/digits.lean Outdated
Comment thread src/data/nat/digits.lean
Comment on lines +473 to +478
/--
Applying `(digits b ∘ of_digits b)` will create a prefix of the original list if it has proper
digits; it removes trailing zeros.
-/
lemma digits_of_digits_prefix {b : ℕ} {L : list ℕ} (hlt : ∀ a ∈ L, a < b) :
digits b (of_digits b L) <+: L :=
Copy link
Copy Markdown
Collaborator

@kim-em kim-em Jun 7, 2021

Choose a reason for hiding this comment

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

As stated, it feels like this is not a very useful lemma. Surely we want to know what is actually stated in the doc-string, i.e. that you get exactly L with trailing zeros removed?

Given that saying "L with trailing zeroes removed" is perhaps slightly cumbersome, why not instead add the hypothesis that L does not end with 0, and then strengthen the conclusion?

A separate lemma could say that of_digits b (L ++ [0]) = of_digits b L.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(I'm also happy to be convinced that this lemma is useful as is, although I have to say that I'm skeptical that Kaprekar's routine counts as an application. :-)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

(Also --- thanks for the PR! Sorry if the above comment sounds grumpy, I'm just wondering what lemma you actually want.)

@jcommelin jcommelin added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Jun 11, 2021
@bryangingechen
Copy link
Copy Markdown
Collaborator

@Pazzaz gentle ping. Feel free to ask here or on Zulip if you need help with the suggestion above.

@kim-em kim-em added the too-late This PR was ready too late for inclusion in mathlib3 label Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

awaiting-author A reviewer has asked the author a question or requested changes too-late This PR was ready too late for inclusion in mathlib3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants