Zulip Chat Archive

Stream: new members

Topic: solution feedback (MoP exercise sets and modular arithmetic)


rzeta0 (Feb 25 2025 at 16:33):

MoP 9.2 ex 7 is about sets but the detail is about modular arithmetic.

example :
    {n :  | 3  n}  {n :  | 2  n}  {n :  | n ^ 2  1 [ZMOD 6]} := by
  sorry

Question: My solution is probably the longest lean4 code I've ever written. That suggests I've missed a trick. I'd welcome feedback.

My Approach: I did this pen-n-paper first, and took a different approach to the two parts of the proof.

  • The first part can be done algebraically by considering n = 3*k in cases where k is even and odd.. That is, n = 3*(2j) and n=3*(2j+1).The algebra leads to n^2 ≡ 0 or 3 mod 6.
  • The second part I couldn't do with the same algebraic approach so had to do by cases on c where n=2*c. This means testing all 6 cases, which feels like I've missed something.

spoiler MoP Exercise 9.2 ex 7

rzeta0 (Feb 25 2025 at 16:34):

(I should apologise that this is MoP code and won't run in live-lean.)

rzeta0 (Feb 25 2025 at 16:35):

I did also think about using <;> but couldn't see it.

Damiano Testa (Feb 25 2025 at 16:47):

Here is an alternative

Kevin Buzzard (Feb 25 2025 at 20:57):

When I'd been writing Lean 3 for a few months I remember producing a monstrously large proof that 3\sqrt{3} was irrational (perhaps even longer than the code snippet above). I was triumphant when I got it compiling. I then #printed the proof, captured it as an image, ray-traced it, imported it into blender and then one of my kids thickened it up, coloured it in, bent it around and added a little character who could jump on the code so the proof became a platformer with the goal being to jump from one end of the proof to the other (I don't think anyone ever succeeded, the proof was that long). We then took a screenshot of the result, and a year or two later when I was asked by the London Maths Society to write something about Lean I sent them the image and they put it on the front page of their newsletter https://www.lms.ac.uk/sites/lms.ac.uk/files/files/NLMS_484-forweb2.pdf . Maybe there's a moral there somewhere.

rzeta0 (Feb 25 2025 at 23:02):

Love this story - and that is a very cool visualisation* !

( * did I mention that I used to run the London Algorithmic Art meet-up in a previous life ... )


Last updated: May 02 2025 at 03:31 UTC