Skip to content

Commit cb99f5a

Browse files
committed
chore: deprime induction in Archive and SetTheory (leanprover-community#25512)
I have decided that depriming one folder (or part of a folder) at a time is the way to go.
1 parent 6c6e018 commit cb99f5a

29 files changed

+197
-168
lines changed

Archive/Imo/Imo1977Q6.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ then we use it to prove the statement for positive naturals.
1919
namespace Imo1977Q6
2020

2121
theorem imo1977_q6_nat (f : ℕ → ℕ) (h : ∀ n, f (f n) < f (n + 1)) : ∀ n, f n = n := by
22-
have h' : ∀ k n : ℕ, k ≤ n → k ≤ f n := by
23-
intro k
24-
induction' k with k h_ind
25-
· intros; exact Nat.zero_le _
26-
· intro n hk
22+
have h' (k n : ℕ) (hk : k ≤ n) : k ≤ f n := by
23+
induction k generalizing n with
24+
| zero => exact Nat.zero_le _
25+
| succ k h_ind =>
2726
apply Nat.succ_le_of_lt
2827
calc
2928
k ≤ f (f (n - 1)) := h_ind _ (h_ind (n - 1) (le_tsub_of_add_le_right hk))

Archive/Imo/Imo2006Q5.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ theorem Polynomial.isPeriodicPt_eval_two {P : Polynomial ℤ} {t : ℤ}
8989
(fun x => P.eval x)^[n + 1] t - (fun x => P.eval x)^[n] t :=
9090
fun m n => Cycle.chain_iff_pairwise.1 HC' _ HC _ HC
9191
-- The sign of P^n(t) - t is the same as P(t) - t for positive n. Proven by induction on n.
92-
have IH : ∀ n : ℕ, ((fun x => P.eval x)^[n + 1] t - t).sign = (P.eval t - t).sign := by
93-
intro n
94-
induction' n with n IH
95-
· rfl
96-
· apply Eq.trans _ (Int.sign_add_eq_of_sign_eq IH)
92+
have IH (n : ℕ) : ((fun x => P.eval x)^[n + 1] t - t).sign = (P.eval t - t).sign := by
93+
induction n with
94+
| zero => rfl
95+
| succ n IH =>
96+
apply Eq.trans _ (Int.sign_add_eq_of_sign_eq IH)
9797
have H := Heq n.succ 0
9898
dsimp at H ⊢
9999
rw [← H, sub_add_sub_cancel']

Archive/Imo/Imo2013Q1.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ open Imo2013Q1
4343
theorem imo2013_q1 (n : ℕ+) (k : ℕ) :
4444
∃ m : ℕ → ℕ+, (1 : ℚ) + (2 ^ k - 1) / n = ∏ i ∈ Finset.range k, (1 + 1 / (m i : ℚ)) := by
4545
revert n
46-
induction' k with pk hpk
47-
· intro n; use fun (_ : ℕ) => (1 : ℕ+); simp
48-
-- For the base case, any m works.
46+
induction k with
47+
| zero => intro n; use fun (_ : ℕ) => (1 : ℕ+); simp -- For the base case, any m works.
48+
| succ pk hpk =>
4949
intro n
5050
obtain ⟨t, ht : ↑n = t + t⟩ | ⟨t, ht : ↑n = 2 * t + 1⟩ := (n : ℕ).even_or_odd
5151
· -- even case

Archive/Imo/Imo2013Q5.lean

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,17 @@ theorem fx_gt_xm1 {f : ℚ → ℝ} {x : ℚ} (hx : 1 ≤ x)
113113
theorem pow_f_le_f_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n) {x : ℚ} (hx : 1 < x)
114114
(H1 : ∀ x y, 0 < x → 0 < y → f (x * y) ≤ f x * f y) (H4 : ∀ n : ℕ, 0 < n → (n : ℝ) ≤ f n) :
115115
f (x ^ n) ≤ f x ^ n := by
116-
induction' n with pn hpn
117-
· exfalso; exact Nat.lt_asymm hn hn
118-
rcases pn with - | pn
119-
· norm_num
120-
have hpn' := hpn pn.succ_pos
121-
rw [pow_succ x (pn + 1), pow_succ (f x) (pn + 1)]
122-
have hxp : 0 < x := by positivity
123-
calc
124-
f (x ^ (pn + 1) * x) ≤ f (x ^ (pn + 1)) * f x := H1 (x ^ (pn + 1)) x (pow_pos hxp (pn + 1)) hxp
125-
_ ≤ f x ^ (pn + 1) * f x := by gcongr; exact (f_pos_of_pos hxp H1 H4).le
116+
induction n with
117+
| zero => exfalso; exact Nat.lt_asymm hn hn
118+
| succ pn hpn =>
119+
rcases pn with - | pn
120+
· norm_num
121+
have hpn' := hpn pn.succ_pos
122+
rw [pow_succ x (pn + 1), pow_succ (f x) (pn + 1)]
123+
have hxp : 0 < x := by positivity
124+
calc
125+
_ ≤ f (x ^ (pn + 1)) * f x := H1 (x ^ (pn + 1)) x (pow_pos hxp (pn + 1)) hxp
126+
_ ≤ f x ^ (pn + 1) * f x := by gcongr; exact (f_pos_of_pos hxp H1 H4).le
126127

127128
theorem fixed_point_of_pos_nat_pow {f : ℚ → ℝ} {n : ℕ} (hn : 0 < n)
128129
(H1 : ∀ x y, 0 < x → 0 < y → f (x * y) ≤ f x * f y) (H4 : ∀ n : ℕ, 0 < n → (n : ℝ) ≤ f n)
@@ -169,15 +170,16 @@ theorem imo2013_q5 (f : ℚ → ℝ) (H1 : ∀ x y, 0 < x → 0 < y → f (x * y
169170
intro x hx n hn
170171
rcases n with - | n
171172
· exact (lt_irrefl 0 hn).elim
172-
induction' n with pn hpn
173-
· norm_num
174-
calc
175-
↑(pn + 2) * f x = (↑pn + 1 + 1) * f x := by norm_cast
176-
_ = (↑pn + 1) * f x + f x := by ring
177-
_ ≤ f (↑pn.succ * x) + f x := mod_cast add_le_add_right (hpn pn.succ_pos) (f x)
178-
_ ≤ f ((↑pn + 1) * x + x) := by exact_mod_cast H2 _ _ (mul_pos pn.cast_add_one_pos hx) hx
179-
_ = f ((↑pn + 1 + 1) * x) := by ring_nf
180-
_ = f (↑(pn + 2) * x) := by norm_cast
173+
induction n with
174+
| zero => norm_num
175+
| succ pn hpn =>
176+
calc
177+
↑(pn + 2) * f x = (↑pn + 1 + 1) * f x := by norm_cast
178+
_ = (↑pn + 1) * f x + f x := by ring
179+
_ ≤ f (↑pn.succ * x) + f x := mod_cast add_le_add_right (hpn pn.succ_pos) (f x)
180+
_ ≤ f ((↑pn + 1) * x + x) := by exact_mod_cast H2 _ _ (mul_pos pn.cast_add_one_pos hx) hx
181+
_ = f ((↑pn + 1 + 1) * x) := by ring_nf
182+
_ = f (↑(pn + 2) * x) := by norm_cast
181183
have H4 : ∀ n : ℕ, 0 < n → (n : ℝ) ≤ f n := by
182184
intro n hn
183185
have hf1 : 1 ≤ f 1 := by

Archive/Imo/Imo2019Q1.lean

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ theorem imo2019_q1 (f : ℤ → ℤ) :
3939
-- Hence, `f` is an affine map, `f b = f 0 + m * b`
4040
obtain ⟨c, H⟩ : ∃ c, ∀ b, f b = c + m * b := by
4141
refine ⟨f 0, fun b => ?_⟩
42-
induction' b with b ihb b ihb
43-
· simp
44-
· simp [H, ihb, mul_add, add_assoc]
45-
· rw [← sub_eq_of_eq_add (H _)]
42+
induction b with
43+
| zero => simp
44+
| succ b ihb => simp [H, ihb, mul_add, add_assoc]
45+
| pred b ihb =>
46+
rw [← sub_eq_of_eq_add (H _)]
4647
simp [ihb]; ring
4748
-- Now use `hf 0 0` and `hf 0 1` to show that `m ∈ {0, 2}`
4849
have H3 : 2 * c = m * c := by simpa [H, mul_add] using hf 0 0

Archive/Imo/Imo2019Q4.lean

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,21 @@ theorem upper_bound {k n : ℕ} (hk : k > 0)
6161
_ < (∑ i ∈ range n, i)! := ?_
6262
_ ≤ k ! := by gcongr
6363
clear h h2
64-
induction' n, hn using Nat.le_induction with n' hn' IH
65-
· decide
66-
let A := ∑ i ∈ range n', i
67-
have le_sum : ∑ i ∈ range 6, i ≤ A := by
68-
apply sum_le_sum_of_subset
69-
simpa using hn'
70-
calc 2 ^ ((n' + 1) * (n' + 1))
71-
2 ^ (n' * n' + 4 * n') := by gcongr <;> linarith
72-
_ = 2 ^ (n' * n') * (2 ^ 4) ^ n' := by rw [← pow_mul, ← pow_add]
73-
_ < A ! * (2 ^ 4) ^ n' := by gcongr
74-
_ = A ! * (15 + 1) ^ n' := rfl
75-
_ ≤ A ! * (A + 1) ^ n' := by gcongr; exact le_sum
76-
_ ≤ (A + n')! := factorial_mul_pow_le_factorial
77-
_ = (∑ i ∈ range (n' + 1), i)! := by rw [sum_range_succ]
64+
induction n, hn using Nat.le_induction with
65+
| base => decide
66+
| succ n' hn' IH =>
67+
let A := ∑ i ∈ range n', i
68+
have le_sum : ∑ i ∈ range 6, i ≤ A := by
69+
apply sum_le_sum_of_subset
70+
simpa using hn'
71+
calc 2 ^ ((n' + 1) * (n' + 1))
72+
2 ^ (n' * n' + 4 * n') := by gcongr <;> linarith
73+
_ = 2 ^ (n' * n') * (2 ^ 4) ^ n' := by rw [← pow_mul, ← pow_add]
74+
_ < A ! * (2 ^ 4) ^ n' := by gcongr
75+
_ = A ! * (15 + 1) ^ n' := rfl
76+
_ ≤ A ! * (A + 1) ^ n' := by gcongr; exact le_sum
77+
_ ≤ (A + n')! := factorial_mul_pow_le_factorial
78+
_ = (∑ i ∈ range (n' + 1), i)! := by rw [sum_range_succ]
7879

7980
end Imo2019Q4
8081

Archive/Imo/Imo2024Q1.lean

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,14 @@ lemma mem_Ico_one_of_mem_Ioo (h : α ∈ Set.Ioo 0 2) : α ∈ Set.Ico 1 2 := by
9999
lemma mem_Ico_n_of_mem_Ioo (h : α ∈ Set.Ioo 0 2) {n : ℕ} (hn : 0 < n) :
100100
α ∈ Set.Ico ((2 * n - 1) / n : ℝ) 2 := by
101101
suffices ∑ i ∈ Finset.Icc 1 n, ⌊i * α⌋ = n ^ 2 ∧ α ∈ Set.Ico ((2 * n - 1) / n : ℝ) 2 from this.2
102-
induction' n, hn using Nat.le_induction with k kpos hk
103-
· obtain ⟨h1, h2⟩ := hc.mem_Ico_one_of_mem_Ioo h
102+
induction n, hn using Nat.le_induction with
103+
| base =>
104+
obtain ⟨h1, h2⟩ := hc.mem_Ico_one_of_mem_Ioo h
104105
simp only [zero_add, Finset.Icc_self, Finset.sum_singleton, Nat.cast_one, one_mul, one_pow,
105106
Int.floor_eq_iff, Int.cast_one, mul_one, div_one, Set.mem_Ico, tsub_le_iff_right]
106107
exact ⟨⟨h1, by linarith⟩, by linarith, h2⟩
107-
· rcases hk with ⟨hks, hkl, hk2⟩
108+
| succ k kpos hk =>
109+
rcases hk with ⟨hks, hkl, hk2⟩
108110
have hs : (∑ i ∈ Finset.Icc 1 (k + 1), ⌊i * α⌋) =
109111
⌊(k + 1 : ℕ) * α⌋ + ((k : ℕ) : ℤ) ^ 2 := by
110112
have hn11 : k + 1 ∉ Finset.Icc 1 k := by

Archive/MiuLanguage/DecisionSuf.lean

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ open MiuAtom List Nat
5353
where `count I w` is a power of 2.
5454
-/
5555
private theorem der_cons_replicate (n : ℕ) : Derivable (M :: replicate (2 ^ n) I) := by
56-
induction' n with k hk
57-
· -- base case
58-
constructor
59-
· -- inductive step
56+
induction n with
57+
| zero => constructor
58+
| succ k hk =>
6059
rw [pow_add, pow_one 2, mul_two, replicate_add]
6160
exact Derivable.r2 hk
6261

@@ -84,10 +83,12 @@ to produce another `Derivable` `Miustr`.
8483
-/
8584
theorem der_of_der_append_replicate_U_even {z : Miustr} {m : ℕ}
8685
(h : Derivable (z ++ ↑(replicate (m * 2) U))) : Derivable z := by
87-
induction' m with k hk
88-
· revert h
86+
induction m with
87+
| zero =>
88+
revert h
8989
rw [replicate, append_nil]; exact id
90-
· apply hk
90+
| succ k hk =>
91+
apply hk
9192
simp only [succ_mul, replicate_add] at h
9293
rw [← append_nil ↑(z ++ ↑(replicate (k * 2) U))]
9394
apply Derivable.r4
@@ -109,9 +110,11 @@ theorem der_cons_replicate_I_replicate_U_append_of_der_cons_replicate_I_append (
109110
(hder : Derivable (↑(M :: replicate (c + 3 * k) I) ++ xs)) :
110111
Derivable (↑(M :: (replicate c I ++ replicate k U)) ++ xs) := by
111112
revert xs
112-
induction' k with a ha
113-
· simp only [replicate, zero_eq, mul_zero, add_zero, append_nil, forall_true_iff, imp_self]
114-
· intro xs
113+
induction k with
114+
| zero =>
115+
simp only [replicate, zero_eq, mul_zero, add_zero, append_nil, forall_true_iff, imp_self]
116+
| succ a ha =>
117+
intro xs
115118
specialize ha (U :: xs)
116119
intro h₂
117120
-- We massage the goal into a form amenable to the application of `ha`.
@@ -141,18 +144,20 @@ theorem add_mod2 (a : ℕ) : ∃ t, a + a % 2 = t * 2 := by
141144

142145
private theorem le_pow2_and_pow2_eq_mod3' (c : ℕ) (x : ℕ) (h : c = 1 ∨ c = 2) :
143146
∃ m : ℕ, c + 3 * x ≤ 2 ^ m ∧ 2 ^ m % 3 = c % 3 := by
144-
induction' x with k hk
145-
· use c + 1
147+
induction x with
148+
| zero =>
149+
use c + 1
146150
rcases h with hc | hc <;> · rw [hc]; norm_num
147-
rcases hk with ⟨g, hkg, hgmod⟩
148-
by_cases hp : c + 3 * (k + 1) ≤ 2 ^ g
149-
· use g, hp, hgmod
150-
refine ⟨g + 2, ?_, ?_⟩
151-
· rw [mul_succ, ← add_assoc, pow_add]
152-
change c + 3 * k + 32 ^ g * (1 + 3); rw [mul_add (2 ^ g) 1 3, mul_one]
153-
linarith [hkg, @Nat.one_le_two_pow g]
154-
· rw [pow_add, ← mul_one c]
155-
exact ModEq.mul hgmod rfl
151+
| succ k hk =>
152+
rcases hk with ⟨g, hkg, hgmod⟩
153+
by_cases hp : c + 3 * (k + 1) ≤ 2 ^ g
154+
· use g, hp, hgmod
155+
refine ⟨g + 2, ?_, ?_⟩
156+
· rw [mul_succ, ← add_assoc, pow_add]
157+
change c + 3 * k + 32 ^ g * (1 + 3); rw [mul_add (2 ^ g) 1 3, mul_one]
158+
linarith [hkg, @Nat.one_le_two_pow g]
159+
· rw [pow_add, ← mul_one c]
160+
exact ModEq.mul hgmod rfl
156161

157162
/-- If `a` is 1 or 2 modulo 3, then exists `k` a power of 2 for which `a ≤ k` and `a ≡ k [MOD 3]`.
158163
-/
@@ -245,9 +250,10 @@ conditions under which `count I ys = length ys`.
245250
-/
246251
theorem count_I_eq_length_of_count_U_zero_and_neg_mem {ys : Miustr} (hu : count U ys = 0)
247252
(hm : M ∉ ys) : count I ys = length ys := by
248-
induction' ys with x xs hxs
249-
· rfl
250-
· cases x
253+
induction ys with
254+
| nil => rfl
255+
| cons x xs hxs =>
256+
cases x
251257
· -- case `x = M` gives a contradiction.
252258
exfalso; exact hm mem_cons_self
253259
· -- case `x = I`
@@ -282,9 +288,10 @@ relate to `count U`.
282288

283289

284290
theorem mem_of_count_U_eq_succ {xs : Miustr} {k : ℕ} (h : count U xs = succ k) : U ∈ xs := by
285-
induction' xs with z zs hzs
286-
· exfalso; rw [count] at h; contradiction
287-
· rw [mem_cons]
291+
induction xs with
292+
| nil => exfalso; rw [count] at h; contradiction
293+
| cons z zs hzs =>
294+
rw [mem_cons]
288295
cases z <;> try exact Or.inl rfl
289296
all_goals right; simp only [count_cons, if_false] at h; exact hzs h
290297

@@ -327,11 +334,10 @@ theorem der_of_decstr {en : Miustr} (h : Decstr en) : Derivable en := by
327334
for induction -/
328335
have hu : ∃ n, count U en = n := exists_eq'
329336
obtain ⟨n, hu⟩ := hu
330-
revert en -- Crucially, we need the induction hypothesis to quantify over `en`
331-
induction' n with k hk
332-
· exact base_case_suf _
333-
· intro ys hdec hus
334-
rcases ind_hyp_suf k ys hus hdec with ⟨as, bs, hyab, habuc, hdecab⟩
337+
induction n generalizing en with
338+
| zero => exact base_case_suf _ h hu
339+
| succ k hk =>
340+
rcases ind_hyp_suf k en hu h with ⟨as, bs, hyab, habuc, hdecab⟩
335341
have h₂ : Derivable (↑(M :: as) ++ ↑[I, I, I] ++ bs) := hk hdecab habuc
336342
rw [hyab]
337343
exact Derivable.r3 h₂

Archive/OxfordInvariants/Summer2021/Week3P1.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ theorem OxfordInvariants.Week3P1 (n : ℕ) (a : ℕ → ℕ) (a_pos : ∀ i ≤
8989
simp_rw [← @Nat.cast_pos α] at a_pos
9090
/- Declare the induction
9191
`ih` will be the induction hypothesis -/
92-
induction' n with n ih
92+
induction n with
93+
| zero =>
9394
/- Base case
9495
Claim that the sum equals `1` -/
95-
· refine ⟨1, ?_, ?_⟩
96+
refine ⟨1, ?_, ?_⟩
9697
-- Check that this indeed equals the sum
9798
· rw [Nat.cast_one, Finset.sum_range_one]
9899
norm_num
@@ -101,6 +102,7 @@ theorem OxfordInvariants.Week3P1 (n : ℕ) (a : ℕ → ℕ) (a_pos : ∀ i ≤
101102
-- Check the divisibility condition
102103
· rw [mul_one, tsub_self]
103104
exact dvd_zero _
105+
| succ n ih =>
104106
/- Induction step
105107
`b` is the value of the previous sum as a natural, `hb` is the proof that it is indeed the
106108
value, and `han` is the divisibility condition -/

Archive/Sensitivity.lean

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,10 @@ variable {n : ℕ}
199199

200200
open Classical in
201201
theorem duality (p q : Q n) : ε p (e q) = if p = q then 1 else 0 := by
202-
induction' n with n IH
203-
· simp [Subsingleton.elim (α := Q 0) p q, ε, e]
204-
· dsimp [ε, e]
202+
induction n with
203+
| zero => simp [Subsingleton.elim (α := Q 0) p q, ε, e]
204+
| succ n IH =>
205+
dsimp [ε, e]
205206
cases hp : p 0 <;> cases hq : q 0
206207
all_goals
207208
simp only [Bool.cond_true, Bool.cond_false, LinearMap.fst_apply, LinearMap.snd_apply,
@@ -210,9 +211,10 @@ theorem duality (p q : Q n) : ε p (e q) = if p = q then 1 else 0 := by
210211

211212
/-- Any vector in `V n` annihilated by all `ε p`'s is zero. -/
212213
theorem epsilon_total {v : V n} (h : ∀ p : Q n, (ε p) v = 0) : v = 0 := by
213-
induction' n with n ih
214-
· dsimp [ε] at h; exact h fun _ => true
215-
· obtain ⟨v₁, v₂⟩ := v
214+
induction n with
215+
| zero => dsimp [ε] at h; exact h fun _ => true
216+
| succ n ih =>
217+
obtain ⟨v₁, v₂⟩ := v
216218
ext <;> change _ = (0 : V n) <;> simp only <;> apply ih <;> intro p <;>
217219
[let q : Q n.succ := fun i => if h : i = 0 then true else p (i.pred h);
218220
let q : Q n.succ := fun i => if h : i = 0 then false else p (i.pred h)]
@@ -292,13 +294,13 @@ theorem f_squared (v : V n) : (f n) (f n v) = (n : ℝ) • v := by
292294
`q` the column index). -/
293295

294296
open Classical in
295-
theorem f_matrix : ∀ p q : Q n, |ε q (f n (e p))| = if p ∈ q.adjacent then 1 else 0 := by
296-
induction' n with n IH
297-
· intro p q
297+
theorem f_matrix : ∀ p q : Q n, |ε q (f n (e p))| = if p ∈ q.adjacent then 1 else 0 := fun p q ↦ by
298+
induction n with
299+
| zero =>
298300
dsimp [f]
299301
simp [Q.not_adjacent_zero]
300302
rfl
301-
· intro p q
303+
| succ n IH =>
302304
have ite_nonneg : ite (π q = π p) (1 : ℝ) 00 := by split_ifs <;> norm_num
303305
dsimp only [e, ε, f, V]; rw [LinearMap.prod_apply]; dsimp; cases hp : p 0 <;> cases hq : q 0
304306
all_goals

0 commit comments

Comments
 (0)