Skip to content

Commit

Permalink
chore: move to v4.15.0-rc1, and merge bump/v4.15.0 branch (#1073)
Browse files Browse the repository at this point in the history
Co-authored-by: leanprover-community-mathlib4-bot <[email protected]>
Co-authored-by: Mario Carneiro <[email protected]>
Co-authored-by: Jeremy Tan Jie Rui <[email protected]>
Co-authored-by: Joachim Breitner <[email protected]>
Co-authored-by: Kyle Miller <[email protected]>
Co-authored-by: Matthew Ballard <[email protected]>
Co-authored-by: Henrik Böving <[email protected]>
  • Loading branch information
8 people authored Dec 2, 2024
1 parent 8d6c853 commit 7805acf
Show file tree
Hide file tree
Showing 37 changed files with 321 additions and 1,129 deletions.
1 change: 0 additions & 1 deletion Batteries.lean
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import Batteries.Lean.Meta.SavedState
import Batteries.Lean.Meta.Simp
import Batteries.Lean.Meta.UnusedNames
import Batteries.Lean.MonadBacktrack
import Batteries.Lean.NameMap
import Batteries.Lean.NameMapAttribute
import Batteries.Lean.PersistentHashMap
import Batteries.Lean.PersistentHashSet
Expand Down
6 changes: 0 additions & 6 deletions Batteries/Classes/SatisfiesM.lean
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,6 @@ instance : MonadSatisfying (Except ε) where
| .error e => .error e
val_eq {α p x?} h := by cases x? <;> simp

-- This will be redundant after nightly-2024-11-08.
attribute [ext] ReaderT.ext

instance [Monad m] [LawfulMonad m][MonadSatisfying m] : MonadSatisfying (ReaderT ρ m) where
satisfying {α p x} h :=
have h' := SatisfiesM_ReaderT_eq.mp h
Expand All @@ -264,9 +261,6 @@ instance [Monad m] [LawfulMonad m][MonadSatisfying m] : MonadSatisfying (ReaderT
instance [Monad m] [LawfulMonad m] [MonadSatisfying m] : MonadSatisfying (StateRefT' ω σ m) :=
inferInstanceAs <| MonadSatisfying (ReaderT _ _)

-- This will be redundant after nightly-2024-11-08.
attribute [ext] StateT.ext

instance [Monad m] [LawfulMonad m] [MonadSatisfying m] : MonadSatisfying (StateT ρ m) where
satisfying {α p x} h :=
have h' := SatisfiesM_StateT_eq.mp h
Expand Down
49 changes: 7 additions & 42 deletions Batteries/Data/Array/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ considered.
protected def minD [ord : Ord α]
(xs : Array α) (d : α) (start := 0) (stop := xs.size) : α :=
if h: start < xs.size ∧ start < stop then
xs.minWith (xs.get ⟨start, h.left⟩) (start + 1) stop
xs.minWith xs[start] (start + 1) stop
else
d

Expand All @@ -60,7 +60,7 @@ considered.
protected def min? [ord : Ord α]
(xs : Array α) (start := 0) (stop := xs.size) : Option α :=
if h : start < xs.size ∧ start < stop then
some $ xs.minD (xs.get ⟨start, h.left⟩) start stop
some $ xs.minD xs[start] start stop
else
none

Expand Down Expand Up @@ -135,48 +135,13 @@ A proof by `get_elem_tactic` is provided as a default argument for `h`.
This will perform the update destructively provided that `a` has a reference count of 1 when called.
-/
abbrev setN (a : Array α) (i : Nat) (x : α) (h : i < a.size := by get_elem_tactic) : Array α :=
a.set ⟨i, h⟩ x
a.set i x

/--
`swapN a i j hi hj` swaps two `Nat` indexed entries in an `Array α`.
Uses `get_elem_tactic` to supply a proof that the indices are in range.
`hi` and `hj` are both given a default argument `by get_elem_tactic`.
This will perform the update destructively provided that `a` has a reference count of 1 when called.
-/
abbrev swapN (a : Array α) (i j : Nat)
(hi : i < a.size := by get_elem_tactic) (hj : j < a.size := by get_elem_tactic) : Array α :=
Array.swap a ⟨i,hi⟩ ⟨j, hj⟩

/--
`swapAtN a i h x` swaps the entry with index `i : Nat` in the vector for a new entry `x`.
The old entry is returned alongwith the modified vector.
Automatically generates proof of `i < a.size` with `get_elem_tactic` where feasible.
-/
abbrev swapAtN (a : Array α) (i : Nat) (x : α) (h : i < a.size := by get_elem_tactic) :
α × Array α := swapAt a ⟨i,h⟩ x
@[deprecated (since := "2024-11-24")] alias swapN := swap

/--
`eraseIdxN a i h` Removes the element at position `i` from a vector of length `n`.
`h : i < a.size` has a default argument `by get_elem_tactic` which tries to supply a proof
that the index is valid.
This function takes worst case O(n) time because it has to backshift all elements at positions
greater than i.
-/
abbrev eraseIdxN (a : Array α) (i : Nat) (h : i < a.size := by get_elem_tactic) : Array α :=
a.feraseIdx ⟨i, h⟩

/--
Remove the element at a given index from an array, panics if index is out of bounds.
-/
def eraseIdx! (a : Array α) (i : Nat) : Array α :=
if h : i < a.size then
a.feraseIdx ⟨i, h⟩
else
have : Inhabited (Array α) := ⟨a⟩
panic! s!"index {i} out of bounds"
@[deprecated (since := "2024-11-24")] alias swapAtN := swapAt

/-- `finRange n` is the array of all elements of `Fin n` in order. -/
protected def finRange (n : Nat) : Array (Fin n) := ofFn fun i => i
@[deprecated (since := "2024-11-20")] alias eraseIdxN := eraseIdx

end Array

Expand Down Expand Up @@ -204,7 +169,7 @@ subarray, or `none` if the subarray is empty.
def popHead? (as : Subarray α) : Option (α × Subarray α) :=
if h : as.start < as.stop
then
let head := as.array.get ⟨as.start, Nat.lt_of_lt_of_le h as.stop_le_array_size
let head := as.array[as.start]'(Nat.lt_of_lt_of_le h as.stop_le_array_size)
let tail :=
{ as with
start := as.start + 1
Expand Down
Loading

0 comments on commit 7805acf

Please sign in to comment.