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
feat(archive/imo): formalise 1979 Q1 #4956
Conversation
kbuzzard
commented
Nov 9, 2020
archive/imo/imo1979_q1.lean
Outdated
apply finset.subset.antisymm, | ||
{ intros x hx, | ||
rw mem_filter at hx, | ||
rcases hx with ⟨hx1, m, rfl⟩, | ||
rw mem_map, | ||
use m, | ||
existsi _, refl, | ||
rw mem_range at hx1 ⊢, | ||
linarith }, | ||
{ intros x hx, | ||
rw mem_filter, | ||
rw mem_map at hx, | ||
rcases hx with ⟨a, ha, rfl⟩, | ||
split, | ||
{ rw mem_range at ha ⊢, | ||
change 2 * a < 1320, | ||
linarith }, | ||
{ existsi a, | ||
refl | ||
} | ||
} |
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 it really this hard to prove that filter even (range 1320) = map double (range 660)
? That's awful!
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 do it with slightly fewer lines with
example : filter even (range 1320) = map double (range 660) :=
begin
ext a,
simp only [mem_filter, mem_range, mem_map, double],
split,
{ rintros ⟨x, m, rfl⟩,
refine ⟨m, _, rfl⟩,
rw mem_range,
linarith },
{ rintros ⟨a, ha, rfl⟩,
refine ⟨_, a, rfl⟩,
rw mem_range at ha,
change 2 * a < 1320,
linarith, }
end
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.
In this case, the general form of the lemma seems to be easier to prove
example (n : ℕ) : filter even (range (2*n)) = map double (range n) :=
begin
induction n with k IH,
{ refl },
{ rw [mul_succ, range_succ, range_succ, range_succ, map_insert, filter_insert, if_neg,
filter_insert, if_pos, IH];
simp with parity_simps }
end
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'd think a more general form takes a monotone function, filters an interval on membership of the image of that function and shows the result is the image of an interval given suitable conditions on the orders involved. With special cases for arithmetic progressions, i.e. images of intervals under functions a * x + b
in nat
or int
being equivalent to filtering intervals on some modular arithmetic condition, and versions for odd
and even
being special cases of that. (And most of that making sense for both set
and finset
.) That may not make proofs significantly simpler, but it fits in with mathlib principles, and those more general lemmas about intervals, monotone functions and arithmetic progressions seem plausibly appropriate for mathlib proper.
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 gone with @eric-wieser 's 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.
Having said that, I now feel guilty because one of the main gains that we're getting from formalising IMO solutions is that it shows up gaps in the library...
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.
My suggestions are just a few style comments.
I've only glanced at the proofs so far, but their length suggests to me that we might be missing some API for manipulating sums. I don't have any concrete suggestions yet, but what was your feeling when you were writing the proofs?
Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
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 come back to this and tried to tidy up all the sum proofs, and I think @jsm28 is right. There are some sum lemmas missing in finset.Ico; I think that it's probably best if I do this properly and add them. I'm still working on this PR so I'll leave it as awaiting-author.
@[reducible, nolint fails_quickly] def e : ℚ := ∑ n in range 330, 1 / (n + 660) | ||
@[reducible, nolint fails_quickly] def f : ℚ := ∑ n in range 330, 1 / (1319 - n) | ||
|
||
/- |
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 a module doc?
/- | |
/-! |
Just to clarify what's going on here -- I wanted the parity stuff for another reason so I PR'ed it independently; I embarked upon adding some finset.Ico stuff so I could streamline the sum proofs, but then I heard here that @Vierkantor was in the middle of refactoring it all on the |
Now that all the |
I have pushed a new commit, where I've updated the file to use |
archive/imo/imo1979_q1.lean
Outdated
|
||
The p-adic valuation function on ℚ is ℤ-valued and hence has v(0)=0 (rather than +∞); | ||
we thus had to occasionally deal with funny edge cases which aren't there mathematically. | ||
In retrospect it might have been easier to work with p-adic norms, which are ℚ-valued |
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.
How hard would it be to do this refactor? I think these IMO files should be showcases that look as nice as possible.
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.
@kbuzzard, what did you exactly mean by that? I can't make sense of the "ℚ
-valued" bit. Surely you meant "with_top ℤ
-valued"? If that's really the case, the refactor is arguable.
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 he meant ℝ
-valued, although the norms of p-adic numbers are all in the image of coe : ℚ → ℝ
.
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 meant that valuations have problems with v(0) but norms don't, |0|=0. We have |p^n|=p^{-n} so \Q will do.
/-- The injection ℕ ↪ ℕ sending any n ∈ ℕ to 2 * n | ||
-/ |
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 injection ℕ ↪ ℕ sending any n ∈ ℕ to 2 * n | |
-/ | |
/-- The injection `ℕ ↪ ℕ` sending any `n ∈ ℕ` to `2 * n` -/ |
@kbuzzard Could you please move this PR to https://github.com/leanprover-community/mathzoo ? |
@YaelDillies are you still thinking about working on this? |
Yael reopened this but I'm going to close it again because I see no point in working on a Lean 3 version of this, with mathlib4 so near. |
Mathport can always translate it! |