Skip to content

Commit 11a7850

Browse files
committed
Merge branch 'master' into Komyyy/Mathlib.Init.ZeroOne
2 parents d70c0ae + 7269094 commit 11a7850

File tree

24 files changed

+686
-373
lines changed

24 files changed

+686
-373
lines changed

Mathlib.lean

+2
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,7 @@ import Mathlib.Analysis.SpecialFunctions.Complex.Circle
12141214
import Mathlib.Analysis.SpecialFunctions.Complex.Log
12151215
import Mathlib.Analysis.SpecialFunctions.Complex.LogBounds
12161216
import Mathlib.Analysis.SpecialFunctions.Complex.LogDeriv
1217+
import Mathlib.Analysis.SpecialFunctions.ContinuousFunctionalCalculus.ExpLog
12171218
import Mathlib.Analysis.SpecialFunctions.Exp
12181219
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
12191220
import Mathlib.Analysis.SpecialFunctions.Exponential
@@ -3847,6 +3848,7 @@ import Mathlib.RingTheory.TensorProduct.MvPolynomial
38473848
import Mathlib.RingTheory.Trace.Basic
38483849
import Mathlib.RingTheory.Trace.Defs
38493850
import Mathlib.RingTheory.TwoSidedIdeal.Basic
3851+
import Mathlib.RingTheory.TwoSidedIdeal.Lattice
38503852
import Mathlib.RingTheory.UniqueFactorizationDomain
38513853
import Mathlib.RingTheory.Unramified.Basic
38523854
import Mathlib.RingTheory.Unramified.Derivations

Mathlib/Algebra/Polynomial/Smeval.lean

+37-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ Authors: Scott Carnahan
55
-/
66
import Mathlib.Algebra.Group.NatPowAssoc
77
import Mathlib.Algebra.Polynomial.AlgebraMap
8-
import Mathlib.Algebra.Polynomial.Induction
9-
import Mathlib.Algebra.Polynomial.Eval
108

119
/-!
1210
# Scalar-multiple polynomial evaluation
@@ -292,6 +290,43 @@ theorem smeval_comp : (p.comp q).smeval x = p.smeval (q.smeval x) := by
292290

293291
end NatPowAssoc
294292

293+
section Commute
294+
295+
variable (R : Type*) [Semiring R] (p q : R[X]) {S : Type*} [Semiring S]
296+
[Module R S] [IsScalarTower R S S] [SMulCommClass R S S] {x y : S}
297+
298+
theorem smeval_commute_left (hc : Commute x y) : Commute (p.smeval x) y := by
299+
induction p using Polynomial.induction_on' with
300+
| h_add r s hr hs => exact (smeval_add R r s x) ▸ Commute.add_left hr hs
301+
| h_monomial n a =>
302+
simp only [smeval_monomial]
303+
refine Commute.smul_left ?_ a
304+
induction n with
305+
| zero => simp only [npow_zero, Commute.one_left]
306+
| succ n ih =>
307+
refine (commute_iff_eq (x ^ (n + 1)) y).mpr ?_
308+
rw [commute_iff_eq (x ^ n) y] at ih
309+
rw [pow_succ, ← mul_assoc, ← ih]
310+
exact Commute.right_comm hc (x ^ n)
311+
312+
theorem smeval_commute (hc : Commute x y) : Commute (p.smeval x) (q.smeval y) := by
313+
induction p using Polynomial.induction_on' with
314+
| h_add r s hr hs => exact (smeval_add R r s x) ▸ Commute.add_left hr hs
315+
| h_monomial n a =>
316+
simp only [smeval_monomial]
317+
refine Commute.smul_left ?_ a
318+
induction n with
319+
| zero => simp only [npow_zero, Commute.one_left]
320+
| succ n ih =>
321+
refine (commute_iff_eq (x ^ (n + 1)) (q.smeval y)).mpr ?_
322+
rw [commute_iff_eq (x ^ n) (q.smeval y)] at ih
323+
have hxq : x * q.smeval y = q.smeval y * x := by
324+
refine (commute_iff_eq x (q.smeval y)).mp ?_
325+
exact Commute.symm (smeval_commute_left R q (Commute.symm hc))
326+
rw [pow_succ, ← mul_assoc, ← ih, mul_assoc, hxq, mul_assoc]
327+
328+
end Commute
329+
295330
section Algebra
296331

297332
theorem aeval_eq_smeval {R : Type*} [CommSemiring R] {S : Type*} [Semiring S] [Algebra R S]

Mathlib/Algebra/Polynomial/UnitTrinomial.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ theorem card_support_eq_three (hp : p.IsUnitTrinomial) : p.support.card = 3 := b
150150

151151
theorem ne_zero (hp : p.IsUnitTrinomial) : p ≠ 0 := by
152152
rintro rfl
153-
exact Nat.zero_ne_bit1 1 hp.card_support_eq_three
153+
simpa using hp.card_support_eq_three
154154
#align polynomial.is_unit_trinomial.ne_zero Polynomial.IsUnitTrinomial.ne_zero
155155

156156
theorem coeff_isUnit (hp : p.IsUnitTrinomial) {k : ℕ} (hk : k ∈ p.support) :
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/-
2+
Copyright (c) 2024 Frédéric Dupuis. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Frédéric Dupuis
5+
-/
6+
7+
import Mathlib.Analysis.NormedSpace.Spectrum
8+
import Mathlib.Analysis.SpecialFunctions.Exponential
9+
import Mathlib.Topology.ContinuousFunction.FunctionalCalculus
10+
11+
/-!
12+
# The exponential and logarithm based on the continuous functional calculus
13+
14+
This file defines the logarithm via the continuous functional calculus (CFC) and builds its API.
15+
This allows one to take logs of matrices, operators, elements of a C⋆-algebra, etc.
16+
17+
It also shows that exponentials defined via the continuous functional calculus are equal to
18+
`NormedSpace.exp` (defined via power series) whenever the former are not junk values.
19+
20+
## Main declarations
21+
22+
+ `CFC.log`: the real log function based on the CFC, i.e. `cfc Real.log`
23+
+ `CFC.exp_eq_normedSpace_exp`: exponentials based on the CFC are equal to exponentials based
24+
on power series.
25+
+ `CFC.log_exp` and `CFC.exp_log`: `CFC.log` and `NormedSpace.exp ℝ` are inverses of each other.
26+
27+
## Implementation notes
28+
29+
Since `cfc Real.exp` and `cfc Complex.exp` are strictly less general than `NormedSpace.exp`
30+
(defined via power series), we only give minimal API for these here in order to relate
31+
`NormedSpace.exp` to functions defined via the CFC. In particular, we don't give separate
32+
definitions for them.
33+
34+
## TODO
35+
36+
+ Show that `log (a * b) = log a + log b` whenever `a` and `b` commute (and the same for indexed
37+
products).
38+
+ Relate `CFC.log` to `rpow`, `zpow`, `sqrt`, `inv`.
39+
-/
40+
41+
open NormedSpace
42+
43+
section general_exponential
44+
variable {𝕜 : Type*} {α : Type*} [RCLike 𝕜] [TopologicalSpace α] [CompactSpace α]
45+
46+
lemma NormedSpace.exp_continuousMap_eq (f : C(α, 𝕜)) :
47+
exp 𝕜 f = (⟨exp 𝕜 ∘ f, exp_continuous.comp f.continuous⟩ : C(α, 𝕜)) := by
48+
ext a
49+
simp only [Function.comp_apply, NormedSpace.exp, FormalMultilinearSeries.sum]
50+
have h_sum := NormedSpace.expSeries_summable (𝕂 := 𝕜) f
51+
simp_rw [← ContinuousMap.tsum_apply h_sum a, NormedSpace.expSeries_apply_eq]
52+
simp [NormedSpace.exp_eq_tsum]
53+
54+
end general_exponential
55+
56+
namespace CFC
57+
section RCLikeNormed
58+
59+
variable {𝕜 : Type*} {A : Type*} [RCLike 𝕜] {p : A → Prop} [PartialOrder A] [NormedRing A]
60+
[StarRing A] [StarOrderedRing A] [TopologicalRing A] [NormedAlgebra 𝕜 A] [CompleteSpace A]
61+
[ContinuousFunctionalCalculus 𝕜 p]
62+
[UniqueContinuousFunctionalCalculus 𝕜 A]
63+
64+
lemma exp_eq_normedSpace_exp {a : A} (ha : p a := by cfc_tac) :
65+
cfc (exp 𝕜 : 𝕜 → 𝕜) a = exp 𝕜 a := by
66+
conv_rhs => rw [← cfc_id 𝕜 a ha, cfc_apply id a ha]
67+
have h := (cfcHom_closedEmbedding (R := 𝕜) (show p a from ha)).continuous
68+
have _ : ContinuousOn (exp 𝕜) (spectrum 𝕜 a) := exp_continuous.continuousOn
69+
simp_rw [← map_exp 𝕜 _ h, cfc_apply (exp 𝕜) a ha]
70+
congr 1
71+
ext
72+
simp [exp_continuousMap_eq]
73+
74+
end RCLikeNormed
75+
76+
section RealNormed
77+
78+
variable {A : Type*} {p : A → Prop} [PartialOrder A] [NormedRing A] [StarRing A] [StarOrderedRing A]
79+
[TopologicalRing A] [NormedAlgebra ℝ A] [CompleteSpace A]
80+
[ContinuousFunctionalCalculus ℝ p]
81+
[UniqueContinuousFunctionalCalculus ℝ A]
82+
83+
lemma real_exp_eq_normedSpace_exp {a : A} (ha : p a := by cfc_tac) :
84+
cfc Real.exp a = exp ℝ a :=
85+
Real.exp_eq_exp_ℝ ▸ exp_eq_normedSpace_exp ha
86+
87+
end RealNormed
88+
89+
section ComplexNormed
90+
91+
variable {A : Type*} {p : A → Prop} [PartialOrder A] [NormedRing A] [StarRing A] [StarOrderedRing A]
92+
[TopologicalRing A] [NormedAlgebra ℂ A] [CompleteSpace A]
93+
[ContinuousFunctionalCalculus ℂ p]
94+
[UniqueContinuousFunctionalCalculus ℂ A]
95+
96+
lemma complex_exp_eq_normedSpace_exp {a : A} (ha : p a := by cfc_tac) :
97+
cfc Complex.exp a = exp ℂ a :=
98+
Complex.exp_eq_exp_ℂ ▸ exp_eq_normedSpace_exp ha
99+
100+
end ComplexNormed
101+
102+
103+
section real_log
104+
105+
open scoped ComplexOrder
106+
107+
variable {A : Type*} [PartialOrder A] [NormedRing A] [StarRing A] [StarOrderedRing A]
108+
[TopologicalRing A] [NormedAlgebra ℝ A] [CompleteSpace A]
109+
[ContinuousFunctionalCalculus ℝ (IsSelfAdjoint : A → Prop)]
110+
[UniqueContinuousFunctionalCalculus ℝ A]
111+
112+
/-- The real logarithm, defined via the continuous functional calculus. This can be used on
113+
matrices, operators on a Hilbert space, elements of a C⋆-algebra, etc. -/
114+
noncomputable def log (a : A) : A := cfc Real.log a
115+
116+
@[simp]
117+
protected lemma _root_.IsSelfAdjoint.log {a : A} : IsSelfAdjoint (log a) := cfc_predicate _ a
118+
119+
lemma log_exp (a : A) (ha : IsSelfAdjoint a := by cfc_tac) : log (NormedSpace.exp ℝ a) = a := by
120+
have hcont : ContinuousOn Real.log (Real.exp '' spectrum ℝ a) := by fun_prop (disch := aesop)
121+
rw [log, ← real_exp_eq_normedSpace_exp, ← cfc_comp' Real.log Real.exp a hcont]
122+
simp [cfc_id' (R := ℝ) a]
123+
124+
-- TODO: Relate the hypothesis to a notion of strict positivity
125+
lemma exp_log (a : A) (ha₂ : ∀ x ∈ spectrum ℝ a, 0 < x) (ha₁ : IsSelfAdjoint a := by cfc_tac) :
126+
NormedSpace.exp ℝ (log a) = a := by
127+
have ha₃ : ContinuousOn Real.log (spectrum ℝ a) := by
128+
have : ∀ x ∈ spectrum ℝ a, x ≠ 0 := by peel ha₂ with x hx h; exact h.ne'
129+
fun_prop (disch := assumption)
130+
rw [← real_exp_eq_normedSpace_exp .log, log, ← cfc_comp' Real.exp Real.log a (by fun_prop) ha₃]
131+
conv_rhs => rw [← cfc_id (R := ℝ) a ha₁]
132+
exact cfc_congr (Real.exp_log <| ha₂ · ·)
133+
134+
@[simp] lemma log_zero : log (0 : A) = 0 := by simp [log]
135+
136+
@[simp] lemma log_one : log (1 : A) = 0 := by simp [log]
137+
138+
@[simp]
139+
lemma log_algebraMap {r : ℝ} : log (algebraMap ℝ A r) = algebraMap ℝ A (Real.log r) := by
140+
simp [log]
141+
142+
-- TODO: Relate the hypothesis to a notion of strict positivity
143+
lemma log_smul {r : ℝ} (a : A) (ha₂ : ∀ x ∈ spectrum ℝ a, 0 < x) (hr : 0 < r)
144+
(ha₁ : IsSelfAdjoint a := by cfc_tac) :
145+
log (r • a) = algebraMap ℝ A (Real.log r) + log a := by
146+
have : ∀ x ∈ spectrum ℝ a, x ≠ 0 := by peel ha₂ with x hx h; exact h.ne'
147+
rw [log, ← cfc_smul_id (R := ℝ) r a, ← cfc_comp Real.log (r • ·) a, log]
148+
calc
149+
_ = cfc (fun z => Real.log r + Real.log z) a :=
150+
cfc_congr (Real.log_mul hr.ne' <| ne_of_gt <| ha₂ · ·)
151+
_ = _ := by rw [cfc_const_add _ _ _]
152+
153+
-- TODO: Relate the hypothesis to a notion of strict positivity
154+
lemma log_pow (n : ℕ) (a : A) (ha₂ : ∀ x ∈ spectrum ℝ a, 0 < x)
155+
(ha₁ : IsSelfAdjoint a := by cfc_tac) : log (a ^ n) = n • log a := by
156+
have : ∀ x ∈ spectrum ℝ a, x ≠ 0 := by peel ha₂ with x hx h; exact h.ne'
157+
have ha₂' : ContinuousOn Real.log (spectrum ℝ a) := by fun_prop (disch := assumption)
158+
have ha₂'' : ContinuousOn Real.log ((· ^ n) '' spectrum ℝ a) := by fun_prop (disch := aesop)
159+
rw [log, ← cfc_pow_id (R := ℝ) a n ha₁, ← cfc_comp' Real.log (· ^ n) a ha₂'', log]
160+
simp_rw [Real.log_pow, nsmul_eq_smul_cast ℝ n, cfc_const_mul (n : ℝ) Real.log a ha₂']
161+
162+
end real_log
163+
end CFC

Mathlib/Data/Complex/Exponential.lean

+2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ theorem exp_nat_mul (x : ℂ) : ∀ n : ℕ, exp (n * x) = exp x ^ n
232232
| Nat.succ n => by rw [pow_succ, Nat.cast_add_one, add_mul, exp_add, ← exp_nat_mul _ n, one_mul]
233233
#align complex.exp_nat_mul Complex.exp_nat_mul
234234

235+
@[simp]
235236
theorem exp_ne_zero : exp x ≠ 0 := fun h =>
236237
zero_ne_one <| by rw [← exp_zero, ← add_neg_self x, exp_add, h]; simp
237238
#align complex.exp_ne_zero Complex.exp_ne_zero
@@ -855,6 +856,7 @@ nonrec theorem exp_nat_mul (x : ℝ) (n : ℕ) : exp (n * x) = exp x ^ n :=
855856
ofReal_injective (by simp [exp_nat_mul])
856857
#align real.exp_nat_mul Real.exp_nat_mul
857858

859+
@[simp]
858860
nonrec theorem exp_ne_zero : exp x ≠ 0 := fun h =>
859861
exp_ne_zero x <| by rw [exp, ← ofReal_inj] at h; simp_all
860862
#align real.exp_ne_zero Real.exp_ne_zero

Mathlib/Data/Nat/Bits.lean

+17-55
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Mathlib.Algebra.Group.Basic
77
import Mathlib.Algebra.Group.Nat
88
import Mathlib.Data.Nat.Defs
99
import Mathlib.Init.Data.List.Basic
10-
import Mathlib.Init.Data.Nat.Lemmas
10+
import Mathlib.Init.Data.Nat.Basic
1111
import Mathlib.Tactic.Convert
1212
import Mathlib.Tactic.GeneralizeProofs
1313
import Mathlib.Tactic.Says
@@ -398,74 +398,36 @@ theorem bit_cases_on_inj {C : ℕ → Sort u} (H₁ H₂ : ∀ b n, C (bit b n))
398398
bit_cases_on_injective.eq_iff
399399
#align nat.bit_cases_on_inj Nat.bit_cases_on_inj
400400

401-
protected theorem bit0_eq_zero {n : ℕ} : 2 * n = 0 ↔ n = 0 := by
402-
omega
403-
#align nat.bit0_eq_zero Nat.bit0_eq_zero
401+
#noalign nat.bit0_eq_zero
404402

405403
theorem bit_eq_zero_iff {n : ℕ} {b : Bool} : bit b n = 0 ↔ n = 0 ∧ b = false := by
406404
constructor
407-
· cases b <;> simp [Nat.bit, Nat.bit0_eq_zero, Nat.bit1_ne_zero]; omega
405+
· cases b <;> simp [Nat.bit]; omega
408406
· rintro ⟨rfl, rfl⟩
409407
rfl
410408
#align nat.bit_eq_zero_iff Nat.bit_eq_zero_iff
411409

412-
protected lemma bit0_le (h : n ≤ m) : 2 * n ≤ 2 * m := by
413-
omega
414-
#align nat.bit0_le Nat.bit0_le
415-
416-
protected lemma bit1_le {n m : ℕ} (h : n ≤ m) : 2 * n + 12 * m + 1 := by
417-
omega
418-
#align nat.bit1_le Nat.bit1_le
410+
#noalign nat.bit0_le
411+
#noalign nat.bit1_le
419412

420413
lemma bit_le : ∀ (b : Bool) {m n : ℕ}, m ≤ n → bit b m ≤ bit b n
421-
| true, _, _, h => Nat.bit1_le h
422-
| false, _, _, h => Nat.bit0_le h
414+
| true, _, _, h => by dsimp [bit]; omega
415+
| false, _, _, h => by dsimp [bit]; omega
423416
#align nat.bit_le Nat.bit_le
424417

425-
lemma bit0_le_bit : ∀ (b) {m n : ℕ}, m ≤ n → 2 * m ≤ bit b n
426-
| true, _, _, h => le_of_lt <| Nat.bit0_lt_bit1 h
427-
| false, _, _, h => Nat.bit0_le h
428-
#align nat.bit0_le_bit Nat.bit0_le_bit
429-
430-
lemma bit_le_bit1 : ∀ (b) {m n : ℕ}, m ≤ n → bit b m ≤ 2 * n + 1
431-
| false, _, _, h => le_of_lt <| Nat.bit0_lt_bit1 h
432-
| true, _, _, h => Nat.bit1_le h
433-
#align nat.bit_le_bit1 Nat.bit_le_bit1
434-
435-
lemma bit_lt_bit0 : ∀ (b) {m n : ℕ}, m < n → bit b m < 2 * n
436-
| true, _, _, h => Nat.bit1_lt_bit0 h
437-
| false, _, _, h => Nat.bit0_lt h
438-
#align nat.bit_lt_bit0 Nat.bit_lt_bit0
418+
#noalign nat.bit0_le_bit
419+
#noalign nat.bit_le_bit1
420+
#noalign nat.bit_lt_bit0
439421

440-
protected lemma bit0_lt_bit0 : 2 * m < 2 * n ↔ m < n := by omega
441-
442-
lemma bit_lt_bit (a b) (h : m < n) : bit a m < bit b n :=
443-
lt_of_lt_of_le (bit_lt_bit0 _ h) (bit0_le_bit _ (le_refl _))
422+
lemma bit_lt_bit (a b) (h : m < n) : bit a m < bit b n := calc
423+
bit a m < 2 * n := by cases a <;> dsimp [bit] <;> omega
424+
_ ≤ bit b n := by cases b <;> dsimp [bit] <;> omega
444425
#align nat.bit_lt_bit Nat.bit_lt_bit
445426

446-
@[simp]
447-
lemma bit0_le_bit1_iff : 2 * m ≤ 2 * n + 1 ↔ m ≤ n := by
448-
refine ⟨fun h ↦ ?_, fun h ↦ le_of_lt (Nat.bit0_lt_bit1 h)⟩
449-
rwa [← Nat.lt_succ_iff, n.bit1_eq_succ_bit0, ← n.bit0_succ_eq, Nat.bit0_lt_bit0, Nat.lt_succ_iff]
450-
at h
451-
#align nat.bit0_le_bit1_iff Nat.bit0_le_bit1_iff
452-
453-
@[simp]
454-
lemma bit0_lt_bit1_iff : 2 * m < 2 * n + 1 ↔ m ≤ n :=
455-
fun h => bit0_le_bit1_iff.1 (le_of_lt h), Nat.bit0_lt_bit1⟩
456-
#align nat.bit0_lt_bit1_iff Nat.bit0_lt_bit1_iff
457-
458-
@[simp]
459-
lemma bit1_le_bit0_iff : 2 * m + 12 * n ↔ m < n :=
460-
fun h ↦ by rwa [m.bit1_eq_succ_bit0, Nat.succ_le_iff, Nat.bit0_lt_bit0] at h,
461-
fun h ↦ le_of_lt (Nat.bit1_lt_bit0 h)⟩
462-
#align nat.bit1_le_bit0_iff Nat.bit1_le_bit0_iff
463-
464-
@[simp]
465-
lemma bit1_lt_bit0_iff : 2 * m + 1 < 2 * n ↔ m < n :=
466-
fun h ↦ bit1_le_bit0_iff.1 (le_of_lt h), Nat.bit1_lt_bit0⟩
467-
#align nat.bit1_lt_bit0_iff Nat.bit1_lt_bit0_iff
468-
427+
#noalign nat.bit0_le_bit1_iff
428+
#noalign nat.bit0_lt_bit1_iff
429+
#noalign nat.bit1_le_bit0_iff
430+
#noalign nat.bit1_lt_bit0_iff
469431
#noalign nat.one_le_bit0_iff
470432
#noalign nat.one_lt_bit0_iff
471433
#noalign nat.bit_le_bit_iff

Mathlib/Data/Nat/Bitwise.lean

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ theorem bit_true : bit true = (2 * · + 1) :=
162162

163163
@[simp]
164164
theorem bit_eq_zero {n : ℕ} {b : Bool} : n.bit b = 0 ↔ n = 0 ∧ b = false := by
165-
cases b <;> simp [Nat.bit0_eq_zero, Nat.bit1_ne_zero]
165+
cases b <;> simp [bit, Nat.mul_eq_zero]
166166
#align nat.bit_eq_zero Nat.bit_eq_zero
167167

168168
theorem bit_ne_zero_iff {n : ℕ} {b : Bool} : n.bit b ≠ 0 ↔ n = 0 → b = true := by

Mathlib/Data/Nat/Size.lean

+3-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ theorem lt_size_self (n : ℕ) : n < 2 ^ size n := by
105105
by_cases h : bit b n = 0
106106
· apply this h
107107
rw [size_bit h, shiftLeft_succ, shiftLeft_eq, one_mul]
108-
exact bit_lt_bit0 _ (by simpa [shiftLeft_eq, shiftRight_eq_div_pow] using IH)
108+
cases b <;> dsimp [bit] <;> omega
109109
#align nat.lt_size_self Nat.lt_size_self
110110

111111
theorem size_le {m n : ℕ} : size m ≤ n ↔ m < 2 ^ n :=
@@ -123,7 +123,8 @@ theorem size_le {m n : ℕ} : size m ≤ n ↔ m < 2 ^ n :=
123123
· apply succ_le_succ (IH _)
124124
apply Nat.lt_of_mul_lt_mul_left (a := 2)
125125
simp only [shiftLeft_succ] at *
126-
exact lt_of_le_of_lt (bit0_le_bit b rfl.le) h⟩
126+
refine lt_of_le_of_lt ?_ h
127+
cases b <;> dsimp [bit] <;> omega⟩
127128
#align nat.size_le Nat.size_le
128129

129130
theorem lt_size {m n : ℕ} : m < size n ↔ 2 ^ m ≤ n := by

Mathlib/Data/Num/Lemmas.lean

+3-4
Original file line numberDiff line numberDiff line change
@@ -1600,10 +1600,9 @@ theorem divMod_to_nat (d n : PosNum) :
16001600
-- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
16011601
revert IH; cases' divMod d n with q r; intro IH
16021602
simp only [divMod] at IH ⊢
1603-
apply divMod_to_nat_aux <;> simp
1604-
· rw [← add_assoc, ← add_assoc, ← two_mul, ← two_mul, add_right_comm,
1605-
mul_left_comm, ← mul_add, IH.1]
1606-
· exact IH.2
1603+
apply divMod_to_nat_aux <;> simp only [Num.cast_bit1, cast_bit1]
1604+
· rw [← two_mul, ← two_mul, add_right_comm, mul_left_comm, ← mul_add, IH.1]
1605+
· omega
16071606
· unfold divMod
16081607
-- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
16091608
revert IH; cases' divMod d n with q r; intro IH

0 commit comments

Comments
 (0)