Zulip Chat Archive
Stream: CSLib
Topic: Why shouldn't I use induction'?
Ching-Tsun Chou (Oct 15 2025 at 16:59):
After rebasing on the current main of cslib (commt 4c176f), Lean is now telling me:
The
induction'tactic is discouraged: please strongly consider usinginductioninstead.
Note: This linter can be disabled withset_option linter.style.induction false
Why? Is this specific to cslib, or generally applicable to mathlib as well?
Shreyas Srinivas (Oct 15 2025 at 17:00):
induction’ uses lean 3 syntax and probably won’t get any new features that the induction tactic will.
Shreyas Srinivas (Oct 15 2025 at 17:00):
It already comes with a code action
Shreyas Srinivas (Oct 15 2025 at 17:03):
Technically a deprecation notice could mean that the respective maintainers may choose to remove it in future releases
Ching-Tsun Chou (Oct 15 2025 at 17:06):
It is used in #mil!
Ching-Tsun Chou (Oct 15 2025 at 17:13):
Also, I didn't get this warning yesterday (or ever, for that matter). What changed in cslib or mathlib since yesterday?
Chris Henson (Oct 15 2025 at 17:16):
This is a linter from mathlibStandardSet. You are seeing it now because we just moved to the new Lean release. This is a recent linter that has been added after the last uses of induction' were removed from Mathlib. I would expect MIL to eventually follow suit.
Ching-Tsun Chou (Oct 15 2025 at 17:25):
I see. Thanks!
Ching-Tsun Chou (Oct 15 2025 at 17:50):
I really don't like the syntax of induction.
Eric Wieser (Oct 15 2025 at 17:58):
Is induction n with | foo x | bar y z really worse than induction' n with x y z?
Eric Wieser (Oct 15 2025 at 17:59):
Remember that there is more than one syntax you can use for induction, you don't have to use the one with =>s
Ching-Tsun Chou (Oct 15 2025 at 18:17):
Can you point me to an example of that syntax in mathlib or somewhere else? All I have is #tpil, which doesn't seem to have an example.
Malvin Gattinger (Oct 17 2025 at 06:39):
Maybe Eric has better explanations, but I thought induction _ using blabla is only for using specific induction principles and with should be used to write | foo x | bar y z afterwards? :thinking:
Anyway, running rg "induction n using" or rg "induction n with" in mathlib brings up many examples. Here is for example
private theorem abs_geomSum_le [IsOrderedRing α] : |geomSum a b n| ≤ (n + 1) * max |a| |b| ^ n := by
induction n with | zero => simp [geomSum] | succ n ih => ?_
...
And here is this example:
theorem zero_of_testBit_eq_false {n : ℕ} (h : ∀ i, testBit n i = false) : n = 0 := by
induction n using Nat.binaryRec with | zero => rfl | bit b n hn => ?_
...
Ching-Tsun Chou (Oct 17 2025 at 18:44):
The fact that you have to write zero and succ and => is precisely what I don't like about the syntax of induction.
Shreyas Srinivas (Oct 17 2025 at 18:57):
I prefer this syntax precisely for this reason. You get properly named cases usually corresponding to the constructors of the type
Ching-Tsun Chou (Oct 17 2025 at 19:16):
This may make sense for user-defined inductive types. But does everyone really care about the fact that the natural numbers are inductively defined in Lean using constructors named "zero" and "succ" (rather than some other names)? With induction' you can do inductive proofs on Nat without ever noticing that.
Shreyas Srinivas (Oct 17 2025 at 19:48):
To answer your question, unironically yes. Tracking induction arms is very useful when we are dealing with induction proofs on larger inductive types. It also makes the proof script readable. And fwiw, this debate appears to have reached a settlement sometime ago. The new syntax is here to stay.
Last updated: Dec 20 2025 at 21:32 UTC