Am slowly learning to trust in #Lean4's ability to work with "holes" - missing h...

@tao@mathstodon.xyz

Am slowly learning to trust in #Lean4's ability to work with "holes" - missing hypotheses or variables in a tool that I did not explicitly supply in advance, making my code be much less clunky and flow better. Many thanks to the pull requesters who demonstrated this ability in their contributed code.

For instance, suppose I had to prove \( a / c = b / c \) for some real numbers \( a,b,c\). The tool `div_left_inj'` proves this equation is equivalent to \( a = b \), but only under the hypothesis \( c \neq 0 \) [which we need even if we define division by zero, as discussed earlier]. If I were to have done this a few days ago, I would have first established the hypothesis \( c \neq 0\) by some argument (using the Lean code `have h : c \neq 0 := by <argument>`, and then applied the tool as `rw [div_left_inj' h]`. A little later I learned how to combine these two lines by `rw [div_left_inj' (show c \neq 0 by <argument>)]` or even (in some cases) `rw [div_left_inj' <argument>]`. But now I also realize that one can just write `rw [div_left_inj']` (or just `field_simp`) with no hypothesis whatsoever, and Lean will still reduce to \(a=b\), but also tack on \( c \neq 0\) to the queue of goals to be proved. This removes the need to manually state these sorts of side hypotheses at all, and can lead to cleaner code.

As a small example of this, here is a proof I recently wrote that the function \( g : x \mapsto e^x + a \) is differentiable over the reals. I just apply the existing tools that addition and exponentiation preserve differentiability, and that the identity and constant functions are differentiable, and the proof more or less matches the one one would give in Mathematical English.