Skip to content

Commit 387f915

Browse files
gotrevorclaude
andauthored
chore: Forward-port to Lean/mathlib v4.31.0 (#830)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c089e7a commit 387f915

133 files changed

Lines changed: 671 additions & 494 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Foundation.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module -- shake: keep-all
1+
module -- shake: keep-all --deprecated_module: ignore
22

33
public import Foundation.FirstOrder.Arithmetic.Basic
44
public import Foundation.FirstOrder.Arithmetic.Basic.Hierarchy

Foundation/FirstOrder/Arithmetic/Basic/Hierarchy.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ set_option linter.flexible false in
315315

316316
lemma exsClosure : {n : ℕ} → {φ : Semiformula L ξ n} → Hierarchy 𝚺 (s + 1) φ → Hierarchy 𝚺 (s + 1) (exsClosure φ)
317317
| 0, _, hp => hp
318-
| n + 1, φ, hp => by simpa using exsClosure (hp.exs)
318+
| n + 1, φ, hp => exsClosure (φ := ∃⁰ φ) hp.exs
319319

320320
instance : LogicalConnective.AndOrClosed (Hierarchy Γ s : Semiformula L ξ k → Prop) where
321321
verum := verum _ _ _

Foundation/FirstOrder/Arithmetic/Definability/Absoluteness.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ lemma Defined.shigmaZero_absolute {k} {R : (Fin k → ℕ) → Prop} {R' : (Fin
3030
lemma DefinedFunction.shigmaZero_absolute_func {k} {f : (Fin k → ℕ) → ℕ} {f' : (Fin k → V) → V} {φ : 𝚺₀.Semisentence (k + 1)}
3131
(hf : 𝚺₀.DefinedFunction f φ) (hf' : 𝚺₀.DefinedFunction f' φ) (v : Fin k → ℕ) :
3232
(f v : V) = f' (Nat.cast ∘ v) := by
33-
simpa using Defined.shigmaZero_absolute V hf hf' (f v :> v)
33+
simpa [Function.comp_def] using Defined.shigmaZero_absolute V hf hf' (f v :> v)
3434

3535
lemma sigmaOne_upward_absolute {k} (φ : 𝚺₁.Semisentence k) (v : Fin k → ℕ) :
3636
φ.val.Evalb v → φ.val.Evalb (M := V) (Nat.cast ∘ v) := by
@@ -56,7 +56,7 @@ lemma Defined.shigmaOne_absolute {k} {R : (Fin k → ℕ) → Prop} {R' : (Fin k
5656
lemma DefinedFunction.shigmaOne_absolute_func {k} {f : (Fin k → ℕ) → ℕ} {f' : (Fin k → V) → V} {φ : 𝚺₁.Semisentence (k + 1)}
5757
(hf : 𝚺₁.DefinedFunction f φ) (hf' : 𝚺₁.DefinedFunction f' φ) (v : Fin k → ℕ) :
5858
(f v : V) = f' (Nat.cast ∘ v) := by
59-
simpa using Defined.shigmaOne_absolute V hf.graph_delta hf'.graph_delta (f v :> v)
59+
simpa [Function.comp_def] using Defined.shigmaOne_absolute V hf.graph_delta hf'.graph_delta (f v :> v)
6060

6161
variable {V}
6262

Foundation/FirstOrder/Arithmetic/Definability/BoundedDefinable.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ lemma comp [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {k} {f : (Fin l → V) → V} {g :
5555
choose tg htg using fun i ↦ (hg i).bounded
5656
exact ⟨Rew.subst tg tf, by
5757
intro v
58-
simpa [Semiterm.val_substs]
59-
using le_trans (htf (g · v)) (Structure.Monotone.term_monotone tf (fun i ↦ htg i v) (by simp))⟩
58+
simpa [Semiterm.val_substs, Function.comp_def]
59+
using! le_trans (htf (g · v)) (Structure.Monotone.term_monotone tf (fun i ↦ htg i v) (by simp))⟩
6060

6161
end Bounded
6262

Foundation/FirstOrder/Arithmetic/Definability/Hierarchy.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ lemma ProvablyProperOn.ofProperOn [𝗘𝗤 ℒₒᵣ ⪯ T] {φ : 𝚫-[m].Semi
169169
(h : ∀ (M : Type w) [ORingStructure M] [M↓[ℒₒᵣ] ⊧* T], φ.ProperOn M) : φ.ProvablyProperOn T := by
170170
apply FirstOrder.Arithmetic.complete.{w} T _ ?_
171171
intro M _ _
172-
simpa [models_iff] using (h M).iff
172+
simpa [models_iff] using! (h M).iff
173173

174174
variable {T}
175175

Foundation/FirstOrder/Arithmetic/Exponential/Bit.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ end model
186186
section model
187187

188188
lemma mem_iff_mul_exp_add_exp_add {i a : V} : i ∈ a ↔ ∃ k, ∃ r < Exp.exp i, a = k * Exp.exp (i + 1) + Exp.exp i + r := by
189-
simpa [mem_iff_bit, exp_succ] using lenbit_iff_add_mul (exp_pow2 i) (a := a)
189+
simpa [mem_iff_bit, exp_succ] using! lenbit_iff_add_mul (exp_pow2 i) (a := a)
190190

191191
lemma not_mem_iff_mul_exp_add {i a : V} : i ∉ a ↔ ∃ k, ∃ r < Exp.exp i, a = k * Exp.exp (i + 1) + r := by
192-
simpa [mem_iff_bit, exp_succ] using not_lenbit_iff_add_mul (exp_pow2 i) (a := a)
192+
simpa [mem_iff_bit, exp_succ] using! not_lenbit_iff_add_mul (exp_pow2 i) (a := a)
193193

194194
section empty
195195

@@ -239,13 +239,13 @@ instance : LawfulSingleton V V where
239239
i ∈ insert j a ↔ i = j ∨ i ∈ a := by
240240
by_cases h : j ∈ a <;> simp [h, insert_eq, bitInsert]
241241
· by_cases e : i = j <;> simp [h, e]
242-
· simpa [exp_inj.eq_iff] using
242+
· simpa [exp_inj.eq_iff] using!
243243
lenbit_add_pow2_iff_of_not_lenbit (exp_pow2 i) (exp_pow2 j) h
244244

245245
@[simp] lemma mem_bitRemove_iff {i j a : V} :
246246
i ∈ bitRemove j a ↔ i ≠ j ∧ i ∈ a := by
247247
by_cases h : j ∈ a
248-
· simpa [h, bitRemove, exp_inj.eq_iff] using
248+
· simpa [h, bitRemove, exp_inj.eq_iff] using!
249249
lenbit_sub_pow2_iff_of_lenbit (exp_pow2 i) (exp_pow2 j) h
250250
· simp only [bitRemove, h, ↓reduceIte, ne_eq, iff_and_self]
251251
rintro _ rfl; contradiction
@@ -442,7 +442,7 @@ lemma nonempty_of_pos {a : V} (h : 0 < a) : ∃ i, i ∈ a := by
442442
simp [this] at h
443443

444444
lemma eq_empty_or_nonempty (a : V) : a = ∅ ∨ ∃ i, i ∈ a := by
445-
rcases zero_le a with (rfl | pos)
445+
rcases Arithmetic.zero_le a with (rfl | pos)
446446
· simp [emptyset_def]
447447
· right; exact nonempty_of_pos pos
448448

@@ -457,7 +457,7 @@ lemma isempty_iff {s : V} : s = ∅ ↔ ∀ x, x ∉ s := by
457457
@[simp] lemma empty_subset (s : V) : ∅ ⊆ s := by intro x; simp
458458

459459
lemma lt_of_lt_log {a b : V} (pos : 0 < b) (h : ∀ i ∈ a, i < log b) : a < b := by
460-
rcases zero_le a with (rfl | apos)
460+
rcases Arithmetic.zero_le a with (rfl | apos)
461461
· exact pos
462462
by_contra A
463463
exact not_lt_of_ge (log_monotone <| show b ≤ a by simpa using A) (h (log a) (log_mem_of_pos apos))

Foundation/FirstOrder/Arithmetic/Exponential/Log.lean

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ lemma log_exists_unique_pos {y : V} (hy : 0 < y) : ∃! x, x < y ∧ ∃ y' ≤
2525
exact ⟨x + 1, lt_of_lt_of_le (by simp [hxy]) (succ_le_double_of_pos (pos_of_gt hxy)),
2626
2 * y', by simpa using gey, Exponential.exponential_succ_mul_two.mpr H, by simpa using lty⟩
2727
case odd y IH =>
28-
rcases (zero_le y : 0 ≤ y) with (rfl | pos)
28+
rcases (Arithmetic.zero_le y : 0 ≤ y) with (rfl | pos)
2929
· simp
3030
· rcases (IH pos : ∃ x < y, ∃ y' ≤ y, Exponential x y' ∧ y < 2 * y') with ⟨x, hxy, y', gey, H, lty⟩
3131
exact ⟨x + 1, by simpa using lt_of_lt_of_le hxy (by simp),
@@ -62,7 +62,7 @@ lemma log_lt_self_of_pos {y : V} (pos : 0 < y) : log y < y :=
6262
((Classical.choose!_spec (log_exists_unique y)).2 pos).1
6363

6464
@[simp] lemma log_le_self (a : V) : log a ≤ a := by
65-
rcases zero_le a with (rfl | pos)
65+
rcases Arithmetic.zero_le a with (rfl | pos)
6666
· simp
6767
· exact le_of_lt <| log_lt_self_of_pos pos
6868

@@ -121,9 +121,9 @@ lemma log_mul_pow2 {a p : V} (pos : 0 < a) (pp : Pow2 p) : log (a * p) = log a +
121121
simpa using log_mul_pow2_add_of_lt pos pp pp.pos
122122

123123
lemma log_monotone {a b : V} (h : a ≤ b) : log a ≤ log b := by
124-
rcases zero_le a with (rfl | posa)
124+
rcases Arithmetic.zero_le a with (rfl | posa)
125125
· simp
126-
rcases zero_le b with (rfl | posb)
126+
rcases Arithmetic.zero_le b with (rfl | posb)
127127
· have := lt_of_lt_of_le posa h; simp_all
128128
rcases log_pos posa with ⟨a', ha', Ha, _⟩
129129
rcases log_pos posb with ⟨b', _, Hb, hb⟩
@@ -147,12 +147,12 @@ lemma length_eq_binaryLength (a : V) : ‖a‖ = if 0 < a then log a + 1 else 0
147147
lemma length_of_pos {a : V} (pos : 0 < a) : ‖a‖ = log a + 1 := by simp [length_eq_binaryLength, pos]
148148

149149
@[simp] lemma length_le (a : V) : ‖a‖ ≤ a := by
150-
rcases zero_le a with (rfl | pos)
150+
rcases Arithmetic.zero_le a with (rfl | pos)
151151
· simp
152152
· simp [pos, length_of_pos, ←lt_iff_succ_le, log_lt_self_of_pos]
153153

154154
lemma length_graph {i a : V} : i = ‖a‖ ↔ (0 < a → ∃ k ≤ a, k = log a ∧ i = k + 1) ∧ (a = 0 → i = 0) := by
155-
rcases zero_le a with (rfl | pos)
155+
rcases Arithmetic.zero_le a with (rfl | pos)
156156
· simp
157157
· simp [length_of_pos, pos, pos_iff_ne_zero.mp pos]
158158

@@ -174,7 +174,7 @@ lemma length_two_mul_of_pos {a : V} (pos : 0 < a) : ‖2 * a‖ = ‖a‖ + 1 :=
174174
simp [pos, length_of_pos, log_two_mul_of_pos]
175175

176176
lemma length_two_mul_add_one (a : V) : ‖2 * a + 1‖ = ‖a‖ + 1 := by
177-
rcases zero_le a with (rfl | pos)
177+
rcases Arithmetic.zero_le a with (rfl | pos)
178178
· simp
179179
· simp [pos, length_of_pos, log_two_mul_add_one_of_pos]
180180

@@ -185,7 +185,7 @@ lemma length_mul_pow2 {a p : V} (pos : 0 < a) (pp : Pow2 p) : ‖a * p‖ = ‖a
185185
simp [length_of_pos, pos, pp.pos, log_mul_pow2 pos pp, add_right_comm (log a) (log p) 1]
186186

187187
lemma length_monotone {a b : V} (h : a ≤ b) : ‖a‖ ≤ ‖b‖ := by
188-
rcases zero_le a with (rfl | posa)
188+
rcases Arithmetic.zero_le a with (rfl | posa)
189189
· simp
190190
· simpa [length_of_pos posa, length_of_pos (lt_of_lt_of_le posa h)]
191191
using log_monotone h
@@ -208,13 +208,13 @@ lemma exponential_log_le_self {a b : V} (pos : 0 < a) (h : Exponential (log a) b
208208
assumption
209209

210210
lemma lt_exponential_log_self {a b : V} (h : Exponential (log a) b) : a < 2 * b := by
211-
rcases zero_le a with (rfl | pos)
211+
rcases Arithmetic.zero_le a with (rfl | pos)
212212
· simp at h; simp [h]
213213
rcases log_pos pos with ⟨_, _, H, _⟩; rcases H.uniq h
214214
assumption
215215

216216
lemma lt_exp_len_self {a b : V} (h : Exponential ‖a‖ b) : a < b := by
217-
rcases zero_le a with (rfl | pos)
217+
rcases Arithmetic.zero_le a with (rfl | pos)
218218
· simp at h; simp [h]
219219
have : Exponential (log a + 1) b := by simpa [length_of_pos pos] using h
220220
rcases Exponential.exponential_succ.mp this with ⟨b, rfl, H⟩
@@ -225,7 +225,7 @@ lemma le_iff_le_log_of_exp {x y a : V} (H : Exponential x y) (pos : 0 < a) : y
225225
fun h ↦ by rcases log_pos pos with ⟨a', ha', Haa', _⟩; exact le_trans (Exponential.monotone_le H Haa' h) ha'⟩
226226

227227
lemma le_iff_lt_length_of_exp {x y a : V} (H : Exponential x y) : y ≤ a ↔ x < ‖a‖ := by
228-
rcases zero_le a with (rfl | pos)
228+
rcases Arithmetic.zero_le a with (rfl | pos)
229229
· simpa using pos_iff_ne_zero.mp H.range_pos
230230
simp [le_iff_le_log_of_exp H pos, length_of_pos pos, ←le_iff_lt_succ]
231231

@@ -242,7 +242,7 @@ lemma Exponential.le_log {x y : V} (H : Exponential x y) : x ≤ log y := (le_if
242242
lemma Exponential.lt_length {x y : V} (H : Exponential x y) : x < ‖y‖ := (le_iff_lt_length_of_exp H).mp (by rfl)
243243

244244
lemma lt_exponential_length {a b : V} (h : Exponential ‖a‖ b) : a < b := by
245-
rcases zero_le a with (rfl | pos)
245+
rcases Arithmetic.zero_le a with (rfl | pos)
246246
· simp at h; simp [h]
247247
have : Exponential (log a + 1) b := by simpa [length_of_pos pos] using h
248248
rcases Exponential.exponential_succ.mp this with ⟨b, rfl, H⟩
@@ -261,7 +261,7 @@ lemma sq_len_le_three_mul (a : V) : ‖a‖ ^ 2 ≤ 3 * a := by
261261
_ ≤ 3 * a + 2 * a + a := by simp [←pos_iff_one_le, pos]
262262
_ = 3 * (2 * a) := by simp_all only [←two_add_one_eq_three, two_mul, add_mul, add_assoc, one_mul]
263263
case odd a IH =>
264-
rcases zero_le a with (rfl | pos)
264+
rcases Arithmetic.zero_le a with (rfl | pos)
265265
· simp [←two_add_one_eq_three]
266266
calc
267267
2 * a + 1‖ ^ 2 = (‖a‖ + 1) ^ 2 := by rw [length_two_mul_add_one a]
@@ -380,7 +380,7 @@ lemma bexp_two_mul {a a' x : V} (hx : 2 * x < ‖a‖) (hx' : x < ‖a'‖) :
380380
bexp_eq_of_exp hx (exp_bexp_of_lt hx').bit_zero
381381

382382
lemma bexp_two_mul_succ {a i : V} : bexp (2 * a) (i + 1) = 2 * bexp a i := by
383-
rcases zero_le a with (rfl | pos)
383+
rcases Arithmetic.zero_le a with (rfl | pos)
384384
· simp
385385
rcases show i ≥ ‖a‖ ∨ i < ‖a‖ from le_or_gt ‖a‖ i with (h | h)
386386
· simp [bexp_eq_zero_of_le, h, show2 * a‖ ≤ i + 1 from by simp [length_two_mul_of_pos pos, h]]
@@ -421,7 +421,7 @@ instance : Bounded₂ (fbit : V → V → V) := ⟨‘1’, λ _ ↦ by simp⟩
421421
simp [fbit, bexp_two_mul_add_one_succ, Arithmetic.div_mul]
422422

423423
@[simp] lemma fbit_two_mul_zero_eq_zero (a : V) : fbit (2 * a) 0 = 0 := by
424-
rcases zero_le a with (rfl | pos)
424+
rcases Arithmetic.zero_le a with (rfl | pos)
425425
· simp
426426
· have : bexp (2 * a) 0 = 1 := bexp_eq_of_exp (by simp [pos]) (by simp)
427427
simp [fbit, this]

Foundation/FirstOrder/Arithmetic/Exponential/Pow2.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ lemma not_lenbit_iff_rem {i a : V} : ¬LenBit i a ↔ (a / i) % 2 = 0 := by
141141
@[simp] lemma LenBit.self {a : V} (pos : 0 < a) : LenBit a a := by simp [LenBit.iff_rem, pos]
142142

143143
lemma LenBit.mod {i a k : V} (h : 2 * i ∣ k) : LenBit i (a % k) ↔ LenBit i a := by
144-
have : 0 ≤ i := zero_le i
144+
have : 0 ≤ i := Arithmetic.zero_le i
145145
rcases (eq_or_lt_of_le this) with (rfl | pos)
146146
· simp
147147
rcases h with ⟨k', hk'⟩
@@ -158,7 +158,7 @@ lemma LenBit.mod {i a k : V} (h : 2 * i ∣ k) : LenBit i (a % k) ↔ LenBit i a
158158
@[simp] lemma LenBit.mod_two_mul_self {a i : V} : LenBit i (a % (2 * i)) ↔ LenBit i a := LenBit.mod (by simp)
159159

160160
lemma LenBit.add {i a b : V} (h : 2 * i ∣ b) : LenBit i (a + b) ↔ LenBit i a := by
161-
have : 0 ≤ i := zero_le i
161+
have : 0 ≤ i := Arithmetic.zero_le i
162162
rcases (eq_or_lt_of_le this) with (rfl | pos)
163163
· simp
164164
rcases h with ⟨b', hb'⟩
@@ -307,7 +307,7 @@ lemma four_le {i : V} (hi : Pow2 i) (lt : 2 < i) : 4 ≤ i := by
307307

308308
lemma mul_add_lt_of_mul_lt_of_pos {a b p q : V} (hp : Pow2 p) (hq : Pow2 q)
309309
(h : a * p < q) (hb : b < p) (hbq : b < q) : a * p + b < q := by
310-
rcases zero_le a with (rfl | pos)
310+
rcases Arithmetic.zero_le a with (rfl | pos)
311311
· simp [hbq]
312312
have : p ∣ q :=
313313
dvd_of_le hp hq (le_of_lt <| lt_of_le_of_lt (le_mul_of_pos_left pos) h)

Foundation/FirstOrder/Arithmetic/HFS/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ lemma sUnion_lt_of_pos {a : V} (ha : 0 < a) : ⋃ʰᶠ a < a :=
6464
exact lt_of_lt_of_le (lt_of_mem hi) (le_log_of_mem hx)
6565

6666
@[simp] lemma sUnion_le (a : V) : ⋃ʰᶠ a ≤ a := by
67-
rcases zero_le a with (rfl | pos)
67+
rcases Arithmetic.zero_le a with (rfl | pos)
6868
· simp [←emptyset_def]
6969
· exact le_of_lt (sUnion_lt_of_pos pos)
7070

Foundation/FirstOrder/Arithmetic/HFS/PRF.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ lemma CSeq.exists (l : V) : ∃ s, c.CSeq v s ∧ l + 1 = lh s := by
140140
· apply HierarchySymbol.Definable.exs
141141
apply HierarchySymbol.Definable.and
142142
· exact ⟨p.cseqDef.rew (Rew.embSubsts <| #0 :> fun i ↦ &(v i)), by
143-
intro w; simpa [Matrix.comp_vecCons''] using c.cseq_defined_iff (w 0 :> v)⟩
143+
intro w; simpa [Matrix.comp_vecCons''] using! c.cseq_defined_iff (w 0 :> v)⟩
144144
· definability
145145
case zero =>
146146
exact ⟨!⟦c.zero v⟧, CSeq.initial, by simp⟩

0 commit comments

Comments
 (0)