Zulip Chat Archive

Stream: new members

Topic: How to optimize this proof


Michael Bucko (Nov 16 2024 at 19:57):

I used a couple of new techniques to prove this one. Again, that's a new proof from The Mechanics.., spoiler alert. Can I collapse the calc into a one-liner? Can I use some functional programming approach here to solve this in one line?

Proof

Riccardo Brasca (Nov 16 2024 at 20:00):

I guess ring does it immediately?

Riccardo Brasca (Nov 16 2024 at 20:00):

import Mathlib

example {x y : } (h : x = 2  y = -2) : x * y + 2 * x = 2 * y + 4 := by
  rcases h with rfl | rfl <;> ring

Michael Bucko (Nov 16 2024 at 20:02):

Much better than mine! Thank you :thank_you:

Michael Bucko (Nov 16 2024 at 20:15):

(deleted)

Edward van de Meent (Nov 16 2024 at 20:26):

Michael Bucko said:

Can I collapse the calc into a one-liner?

note that although you can have calc a = b := by foo as a single line, lean doesn't like to parse that, making the lines after very prone to parsing errors. Also, it generally can just be replaced with by foo.


Last updated: May 02 2025 at 03:31 UTC