Skip to content

Commit 2dc3d5a

Browse files
committed
Merge branch 'nightly' of https://github.com/leanprover/lean4 into joachim/issue10749
2 parents f5bd1b6 + 705084d commit 2dc3d5a

File tree

36 files changed

+188
-169
lines changed

36 files changed

+188
-169
lines changed

src/Init/ByCases.lean

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ theorem apply_ite (f : α → β) (P : Prop) [Decidable P] (x y : α) :
4444
/-- A `dite` whose results do not actually depend on the condition may be reduced to an `ite`. -/
4545
@[simp] theorem dite_eq_ite [Decidable P] :
4646
(dite P (fun _ => a) (fun _ => b)) = ite P a b := rfl
47+
48+
-- Remark: dite and ite are "defally equal" when we ignore the proofs.
49+
@[deprecated dite_eq_ite (since := "2025-10-29")]
50+
theorem dif_eq_if (c : Prop) {h : Decidable c} {α : Sort u} (t : α) (e : α) : dite c (fun _ => t) (fun _ => e) = ite c t e :=
51+
match h with
52+
| isTrue _ => rfl
53+
| isFalse _ => rfl

src/Init/Core.lean

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,12 +1188,6 @@ theorem dif_neg {c : Prop} {h : Decidable c} (hnc : ¬c) {α : Sort u} {t : c
11881188
| isTrue hc => absurd hc hnc
11891189
| isFalse _ => rfl
11901190

1191-
-- Remark: dite and ite are "defally equal" when we ignore the proofs.
1192-
theorem dif_eq_if (c : Prop) {h : Decidable c} {α : Sort u} (t : α) (e : α) : dite c (fun _ => t) (fun _ => e) = ite c t e :=
1193-
match h with
1194-
| isTrue _ => rfl
1195-
| isFalse _ => rfl
1196-
11971191
@[macro_inline]
11981192
instance {c t e : Prop} [dC : Decidable c] [dT : Decidable t] [dE : Decidable e] : Decidable (if c then t else e) :=
11991193
match dC with

src/Init/Data/Array/Lemmas.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,8 +2252,6 @@ theorem flatMap_def {xs : Array α} {f : α → Array β} : xs.flatMap f = flatt
22522252
rcases xs with ⟨l⟩
22532253
simp [flatten_toArray, Function.comp_def, List.flatMap_def]
22542254

2255-
@[simp, grind =] theorem flatMap_empty {β} {f : α → Array β} : (#[] : Array α).flatMap f = #[] := rfl
2256-
22572255
theorem flatMap_toList {xs : Array α} {f : α → List β} :
22582256
xs.toList.flatMap f = (xs.flatMap (fun a => (f a).toArray)).toList := by
22592257
rcases xs with ⟨l⟩
@@ -2264,6 +2262,7 @@ theorem flatMap_toList {xs : Array α} {f : α → List β} :
22642262
rcases xs with ⟨l⟩
22652263
simp
22662264

2265+
@[deprecated List.flatMap_toArray_cons (since := "2025-10-29")]
22672266
theorem flatMap_toArray_cons {β} {f : α → Array β} {a : α} {as : List α} :
22682267
(a :: as).toArray.flatMap f = f a ++ as.toArray.flatMap f := by
22692268
simp [flatMap]
@@ -2274,6 +2273,7 @@ theorem flatMap_toArray_cons {β} {f : α → Array β} {a : α} {as : List α}
22742273
intro cs
22752274
induction as generalizing cs <;> simp_all
22762275

2276+
@[deprecated List.flatMap_toArray (since := "2025-10-29")]
22772277
theorem flatMap_toArray {β} {f : α → Array β} {as : List α} :
22782278
as.toArray.flatMap f = (as.flatMap (fun a => (f a).toList)).toArray := by
22792279
simp

src/Init/Data/BitVec/Bitblast.lean

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,12 +635,11 @@ theorem mulRec_eq_mul_signExtend_setWidth (x y : BitVec w) (s : Nat) :
635635
simp only [mulRec_zero_eq, ofNat_eq_ofNat, Nat.reduceAdd]
636636
by_cases y.getLsbD 0
637637
case pos hy =>
638-
simp only [hy, ↓reduceIte, setWidth_one_eq_ofBool_getLsb_zero,
639-
ofBool_true, ofNat_eq_ofNat]
638+
simp only [hy, ↓reduceIte, setWidth_one, ofBool_true, ofNat_eq_ofNat]
640639
rw [setWidth_ofNat_one_eq_ofNat_one_of_lt (by omega)]
641640
simp
642641
case neg hy =>
643-
simp [hy, setWidth_one_eq_ofBool_getLsb_zero]
642+
simp [hy, setWidth_one]
644643
case succ s' hs =>
645644
rw [mulRec_succ_eq, hs]
646645
have heq :

src/Init/Data/BitVec/Lemmas.lean

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ theorem getElem?_eq_none_iff {l : BitVec w} : l[n]? = none ↔ w ≤ n := by
6464
theorem none_eq_getElem?_iff {l : BitVec w} : none = l[n]? ↔ w ≤ n := by
6565
simp
6666

67+
@[simp]
6768
theorem getElem?_eq_none {l : BitVec w} (h : w ≤ n) : l[n]? = none := getElem?_eq_none_iff.mpr h
6869

6970
theorem getElem?_eq (l : BitVec w) (i : Nat) :
@@ -158,7 +159,8 @@ theorem getLsbD_eq_getMsbD (x : BitVec w) (i : Nat) : x.getLsbD i = (decide (i <
158159
apply getLsbD_of_ge
159160
omega
160161

161-
@[simp] theorem getElem?_of_ge (x : BitVec w) (i : Nat) (ge : w ≤ i) : x[i]? = none := by
162+
@[deprecated getElem?_eq_none (since := "2025-10-29")]
163+
theorem getElem?_of_ge (x : BitVec w) (i : Nat) (ge : w ≤ i) : x[i]? = none := by
162164
simp [ge]
163165

164166
@[simp] theorem getMsb?_of_ge (x : BitVec w) (i : Nat) (ge : w ≤ i) : getMsb? x i = none := by
@@ -415,12 +417,18 @@ theorem getElem?_zero_ofNat_one : (BitVec.ofNat (w+1) 1)[0]? = some true := by
415417

416418
-- This does not need to be a `@[simp]` theorem as it is already handled by `getElem?_eq_getElem`.
417419
theorem getElem?_zero_ofBool (b : Bool) : (ofBool b)[0]? = some b := by
418-
simp only [ofBool, ofNat_eq_ofNat, cond_eq_if]
420+
simp only [ofBool, ofNat_eq_ofNat, cond_eq_ite]
419421
split <;> simp_all
420422

421-
@[simp, grind =] theorem getElem_zero_ofBool (b : Bool) : (ofBool b)[0] = b := by
423+
@[simp, grind =]
424+
theorem getElem_ofBool_zero {b : Bool} : (ofBool b)[0] = b := by
422425
rw [getElem_eq_iff, getElem?_zero_ofBool]
423426

427+
428+
@[deprecated getElem_ofBool_zero (since := "2025-10-29")]
429+
theorem getElem_zero_ofBool (b : Bool) : (ofBool b)[0] = b := by
430+
simp
431+
424432
theorem getElem?_succ_ofBool (b : Bool) (i : Nat) : (ofBool b)[i + 1]? = none := by
425433
simp
426434

@@ -431,8 +439,6 @@ theorem getLsbD_ofBool (b : Bool) (i : Nat) : (ofBool b).getLsbD i = ((i = 0) &&
431439
· simp only [ofBool, ofNat_eq_ofNat, cond_true, getLsbD_ofNat, Bool.and_true]
432440
by_cases hi : i = 0 <;> simp [hi] <;> omega
433441

434-
theorem getElem_ofBool_zero {b : Bool} : (ofBool b)[0] = b := by simp
435-
436442
@[simp]
437443
theorem getElem_ofBool {b : Bool} {h : i < 1}: (ofBool b)[i] = b := by
438444
simp [← getLsbD_eq_getElem]
@@ -580,7 +586,7 @@ theorem toInt_eq_toNat_bmod (x : BitVec n) : x.toInt = Int.bmod x.toNat (2^n) :=
580586
simp only [toInt_eq_toNat_cond]
581587
split
582588
next g =>
583-
rw [Int.bmod_pos] <;> simp only [←Int.natCast_emod, toNat_mod_cancel]
589+
rw [Int.bmod_eq_emod_of_lt] <;> simp only [←Int.natCast_emod, toNat_mod_cancel]
584590
omega
585591
next g =>
586592
rw [Int.bmod_neg] <;> simp only [←Int.natCast_emod, toNat_mod_cancel]
@@ -988,7 +994,14 @@ theorem msb_setWidth' (x : BitVec w) (h : w ≤ v) : (x.setWidth' h).msb = (deci
988994
theorem msb_setWidth'' (x : BitVec w) : (x.setWidth (k + 1)).msb = x.getLsbD k := by
989995
simp [BitVec.msb, getMsbD]
990996

997+
/-- Truncating to width 1 produces a bitvector equal to the least significant bit. -/
998+
theorem setWidth_one {x : BitVec w} :
999+
x.setWidth 1 = ofBool (x.getLsbD 0) := by
1000+
ext i
1001+
simp [show i = 0 by omega]
1002+
9911003
/-- zero extending a bitvector to width 1 equals the boolean of the lsb. -/
1004+
@[deprecated setWidth_one (since := "2025-10-29")]
9921005
theorem setWidth_one_eq_ofBool_getLsb_zero (x : BitVec w) :
9931006
x.setWidth 1 = BitVec.ofBool (x.getLsbD 0) := by
9941007
ext i h
@@ -1004,12 +1017,6 @@ theorem setWidth_ofNat_one_eq_ofNat_one_of_lt {v w : Nat} (hv : 0 < v) :
10041017
have hv := (@Nat.testBit_one_eq_true_iff_self_eq_zero i)
10051018
by_cases h : Nat.testBit 1 i = true <;> simp_all
10061019

1007-
/-- Truncating to width 1 produces a bitvector equal to the least significant bit. -/
1008-
theorem setWidth_one {x : BitVec w} :
1009-
x.setWidth 1 = ofBool (x.getLsbD 0) := by
1010-
ext i
1011-
simp [show i = 0 by omega]
1012-
10131020
@[simp, grind =] theorem setWidth_ofNat_of_le (h : v ≤ w) (x : Nat) : setWidth v (BitVec.ofNat w x) = BitVec.ofNat v x := by
10141021
apply BitVec.eq_of_toNat_eq
10151022
simp only [toNat_setWidth, toNat_ofNat]
@@ -1639,11 +1646,11 @@ theorem not_def {x : BitVec v} : ~~~x = allOnes v ^^^ x := rfl
16391646

16401647
@[simp] theorem ofInt_negSucc_eq_not_ofNat {w n : Nat} :
16411648
BitVec.ofInt w (Int.negSucc n) = ~~~.ofNat w n := by
1642-
simp only [BitVec.ofInt, Int.toNat, Int.ofNat_eq_coe, toNat_eq, toNat_ofNatLT, toNat_not,
1649+
simp only [BitVec.ofInt, Int.toNat, Int.ofNat_eq_natCast, toNat_eq, toNat_ofNatLT, toNat_not,
16431650
toNat_ofNat]
16441651
cases h : Int.negSucc n % ((2 ^ w : Nat) : Int)
16451652
case ofNat =>
1646-
rw [Int.ofNat_eq_coe, Int.negSucc_emod] at h
1653+
rw [Int.ofNat_eq_natCast, Int.negSucc_emod] at h
16471654
· dsimp only
16481655
omega
16491656
· omega

src/Init/Data/Bool.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ theorem exists_bool {p : Bool → Prop} : (∃ b, p b) ↔ p false ∨ p true :=
514514
theorem cond_eq_ite {α} (b : Bool) (t e : α) : cond b t e = if b then t else e := by
515515
cases b <;> simp
516516

517+
@[deprecated cond_eq_ite (since := "2025-10-29")]
517518
theorem cond_eq_if : (bif b then x else y) = (if b then x else y) := cond_eq_ite b x y
518519

519520
@[simp] theorem cond_not (b : Bool) (t e : α) : cond (!b) t e = cond b e t := by
@@ -612,7 +613,7 @@ theorem decide_beq_decide (p q : Prop) [dpq : Decidable (p ↔ q)] [dp : Decidab
612613

613614
end Bool
614615

615-
export Bool (cond_eq_if xor and or not)
616+
export Bool (cond_eq_if cond_eq_ite xor and or not)
616617

617618
/-! ### decide -/
618619

src/Init/Data/Dyadic/Basic.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ theorem toRat_add (x y : Dyadic) : toRat (x + y) = toRat x + toRat y := by
287287
· rename_i h
288288
cases Int.sub_eq_iff_eq_add.mp h
289289
rw [toRat_ofOdd_eq_mkRat, Rat.mkRat_eq_iff (NeZero.ne _) (NeZero.ne _)]
290-
simp only [succ_eq_add_one, Int.ofNat_eq_coe, Int.add_shiftLeft, ← Int.shiftLeft_add,
290+
simp only [succ_eq_add_one, Int.ofNat_eq_natCast, Int.add_shiftLeft, ← Int.shiftLeft_add,
291291
Int.natCast_mul, Int.natCast_shiftLeft, Int.shiftLeft_mul_shiftLeft, Int.add_mul]
292292
congr 2 <;> omega
293293
· rename_i h
@@ -438,7 +438,7 @@ theorem toDyadic_mkRat (a : Int) (b : Nat) (prec : Int) :
438438
rcases h : mkRat a b with ⟨n, d, hnz, hr⟩
439439
obtain ⟨m, hm, rfl, rfl⟩ := Rat.mkRat_num_den hb h
440440
cases prec
441-
· simp only [Rat.toDyadic, Int.ofNat_eq_coe, Int.toNat_natCast, Int.toNat_neg_natCast,
441+
· simp only [Rat.toDyadic, Int.ofNat_eq_natCast, Int.toNat_natCast, Int.toNat_neg_natCast,
442442
shiftLeft_zero, Int.natCast_mul]
443443
rw [Int.mul_comm d, ← Int.ediv_ediv (by simp), ← Int.shiftLeft_mul,
444444
Int.mul_ediv_cancel _ (by simpa using hm)]
@@ -463,7 +463,7 @@ theorem toRat_toDyadic (x : Rat) (prec : Int) :
463463
rw [Rat.floor_def, Int.shiftLeft_eq, Nat.shiftLeft_eq]
464464
match prec with
465465
| .ofNat prec =>
466-
simp only [Int.ofNat_eq_coe, Int.toNat_natCast, Int.toNat_neg_natCast, Nat.pow_zero,
466+
simp only [Int.ofNat_eq_natCast, Int.toNat_natCast, Int.toNat_neg_natCast, Nat.pow_zero,
467467
Nat.mul_one]
468468
have : (2 ^ prec : Rat) = ((2 ^ prec : Nat) : Rat) := by simp
469469
rw [Rat.zpow_natCast, this, Rat.mul_def']

src/Init/Data/Dyadic/Round.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ theorem roundDown_le {x : Dyadic} {prec : Int} : roundDown x prec ≤ x :=
3636
refine Lean.Grind.OrderedRing.mul_le_mul_of_nonneg_right ?_ (Rat.zpow_nonneg (by decide))
3737
rw [Int.shiftRight_eq_div_pow]
3838
rw [← Lean.Grind.Field.IsOrdered.mul_le_mul_iff_of_pos_right (c := 2^(Int.ofNat l)) (Rat.zpow_pos (by decide))]
39-
simp only [Int.natCast_pow, Int.cast_ofNat_Int, Int.ofNat_eq_coe]
39+
simp only [Int.natCast_pow, Int.cast_ofNat_Int, Int.ofNat_eq_natCast]
4040
rw [Rat.mul_assoc, ← Rat.zpow_add (by decide), Int.add_left_neg, Rat.zpow_zero, Rat.mul_one]
4141
have : (2 : Rat) ^ (l : Int) = (2 ^ l : Int) := by
4242
rw [Rat.zpow_natCast, Rat.intCast_pow, Rat.intCast_ofNat]

src/Init/Data/Fin/Lemmas.lean

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ theorem succ_cast_eq {n' : Nat} (i : Fin n) (h : n = n') :
547547
@[simp] theorem cast_castSucc {n' : Nat} {h : n + 1 = n' + 1} {i : Fin n} :
548548
i.castSucc.cast h = (i.cast (Nat.succ.inj h)).castSucc := rfl
549549

550-
theorem castSucc_lt_succ (i : Fin n) : i.castSucc < i.succ :=
550+
theorem castSucc_lt_succ {i : Fin n} : i.castSucc < i.succ :=
551551
lt_def.2 <| by simp only [coe_castSucc, val_succ, Nat.lt_succ_self]
552552

553553
theorem le_castSucc_iff {i : Fin (n + 1)} {j : Fin n} : i ≤ j.castSucc ↔ i < j.succ := by
@@ -587,15 +587,20 @@ theorem castSucc_pos [NeZero n] {i : Fin n} (h : 0 < i) : 0 < i.castSucc := by
587587
theorem castSucc_ne_zero_iff [NeZero n] {a : Fin n} : a.castSucc ≠ 0 ↔ a ≠ 0 :=
588588
not_congr <| castSucc_eq_zero_iff
589589

590+
@[simp, grind _=_]
591+
theorem castSucc_succ (i : Fin n) : i.succ.castSucc = i.castSucc.succ := rfl
592+
593+
@[deprecated castSucc_succ (since := "2025-10-29")]
590594
theorem castSucc_fin_succ (n : Nat) (j : Fin n) :
591-
j.succ.castSucc = (j.castSucc).succ := by simp [Fin.ext_iff]
595+
j.succ.castSucc = (j.castSucc).succ := by simp
592596

593597
@[simp]
594598
theorem coeSucc_eq_succ {a : Fin n} : a.castSucc + 1 = a.succ := by
595599
cases n
596600
· exact a.elim0
597601
· simp [Fin.ext_iff, add_def, Nat.mod_eq_of_lt (Nat.succ_lt_succ a.is_lt)]
598602

603+
@[deprecated castSucc_lt_succ (since := "2025-10-29")]
599604
theorem lt_succ {a : Fin n} : a.castSucc < a.succ := by
600605
rw [castSucc, lt_def, coe_castAdd, val_succ]; exact Nat.lt_succ_self a.val
601606

@@ -699,9 +704,6 @@ theorem rev_castSucc (k : Fin n) : rev (castSucc k) = succ (rev k) := k.rev_cast
699704

700705
theorem rev_succ (k : Fin n) : rev (succ k) = castSucc (rev k) := k.rev_addNat 1
701706

702-
@[simp, grind _=_]
703-
theorem castSucc_succ (i : Fin n) : i.succ.castSucc = i.castSucc.succ := rfl
704-
705707
@[simp, grind =]
706708
theorem castLE_refl (h : n ≤ n) (i : Fin n) : i.castLE h = i := rfl
707709

src/Init/Data/Int/Basic.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ protected theorem zero_ne_one : (0 : Int) ≠ 1 := nofun
8080

8181
/-! ## Coercions -/
8282

83-
@[simp] theorem ofNat_eq_coe : Int.ofNat n = Nat.cast n := rfl
83+
@[simp] theorem ofNat_eq_natCast (n : Nat) : Int.ofNat n = n := rfl
84+
85+
@[deprecated ofNat_eq_natCast (since := "2025-10-29")]
86+
theorem ofNat_eq_coe : Int.ofNat n = Nat.cast n := rfl
8487

8588
@[simp] theorem ofNat_zero : ((0 : Nat) : Int) = 0 := rfl
8689

0 commit comments

Comments
 (0)