lean4-htt/tests/lean/run/indUsingLet.lean
Joachim Breitner fa058ed228
fix: include let bindings when determining altParamNums for eliminators (#3505)
Else the `case` will now allow introducing all necessary variables.

Induction principles with `let` in the types of the cases will be more
common with #3432.

This implementation no longer reduces the type as it goes, but really
only counts
manifest foralls and lets. I find this more sensible and predictable: If
you have
```
theorem induction₂_symm {P : EReal → EReal → Prop} (symm : Symmetric P) …
```
then previously, writing
```
case symm => 
```
would actually bring a fresh `x` and `y` and variable `h : P x y` into
scope and produce a
goal of `P y x`, because `Symmetric P` happens to be
```
def Symmetric := ∀ ⦃x y⦄, x ≺ y → y ≺ x
```

After this change, after `case symm =>` will leave `Symmetric P` as the
goal.

This gives more control to the author of the induction hypothesis about
the actual
goal of the cases. This shows up in mathlib in two places; fixes in
https://github.com/leanprover-community/mathlib4/pull/11023.
I consider these improvements.
2024-02-28 13:14:34 +00:00

14 lines
367 B
Text

theorem some_induction
{motive : Nat → Prop}
(zero : motive 0)
(succ : forall n, 0 < n → let m := n - 1; motive m → motive n) :
∀ n, motive n
| 0 => zero
| n+1 => succ (n+1) (Nat.zero_lt_succ n) (some_induction zero succ n)
example (n : Nat) : n = n := by
induction n using some_induction
case zero => rfl
case succ n _h _m _IH =>
rfl