Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c0834e9
chore: add implicit_reducible/expose attributes to preparatory defini…
leodemoura Apr 4, 2026
414b63f
test: update tests for defeq changes
leodemoura Apr 4, 2026
aefaa70
chore: add implicit_reducible/expose attributes to library definitions
leodemoura Apr 5, 2026
05d6603
feat: enable `backward.isDefEq.respectTransparency.types` by default
leodemoura Apr 5, 2026
4b7a17b
test: update tests for defeq changes
leodemoura Apr 5, 2026
94b47f3
fix: add `Option.map_some` to `modify_eq_alter` simp sets
kim-em Apr 30, 2026
5e3a761
fix: remove @[expose] when unnecessary, fixing stage2 warnings in #13…
datokrat May 4, 2026
dc4f824
fix errors from rebasing
datokrat May 7, 2026
37c3ca5
remove respectTransparency.types false
TwoFX Apr 7, 2026
e11137d
remove local attributes
datokrat May 7, 2026
0fda8dd
cleanup
datokrat May 7, 2026
cac4e8e
dsimproc test
datokrat May 8, 2026
5512382
snapshot
datokrat May 8, 2026
699c4e4
Revert "snapshot"
datokrat May 8, 2026
1154ffc
remove test files; I gave up trying to satisfy the dsimprocs for now
datokrat May 8, 2026
1d83861
Revert "remove test files; I gave up trying to satisfy the dsimprocs …
datokrat May 12, 2026
b40f289
implicit -> instance
datokrat May 12, 2026
551318b
Reapply "snapshot"
datokrat May 12, 2026
6f02c22
poke
datokrat May 12, 2026
9f31b42
it compiles
datokrat May 12, 2026
1dca40a
linter
datokrat May 16, 2026
a26b33e
make Not implicit_reducible
datokrat May 23, 2026
9ab7865
less instance_reducible
datokrat May 28, 2026
fb4cb65
shiftLeft/shiftRight implicit_reducible
datokrat May 29, 2026
f358484
rebasing fixes
datokrat May 29, 2026
bc527c4
more implicit_reducible, fixing mathlib linter errors
datokrat May 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Init/Control/Except.lean
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ end Except
/--
Adds exceptions of type `ε` to a monad `m`.
-/
def ExceptT (ε : Type u) (m : Type u → Type v) (α : Type u) : Type v :=
@[implicit_reducible] def ExceptT (ε : Type u) (m : Type u → Type v) (α : Type u) : Type v :=
m (Except ε α)

/--
Expand Down
2 changes: 1 addition & 1 deletion src/Init/Control/ExceptCps.lean
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Adds exceptions of type `ε` to a monad `m`.
Instead of using `Except ε` to model exceptions, this implementation uses continuation passing
style. This has different performance characteristics from `ExceptT ε`.
-/
@[expose] def ExceptCpsT (ε : Type u) (m : Type u → Type v) (α : Type u) := (β : Type u) → (α → m β) → (ε → m β) → m β
@[expose, instance_reducible] def ExceptCpsT (ε : Type u) (m : Type u → Type v) (α : Type u) := (β : Type u) → (α → m β) → (ε → m β) → m β

namespace ExceptCpsT

Expand Down
2 changes: 1 addition & 1 deletion src/Init/Control/Id.lean
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def containsFive (xs : List Nat) : Bool := Id.run do
true
```
-/
@[expose] def Id (type : Type u) : Type u := type
@[expose, implicit_reducible] def Id (type : Type u) : Type u := type

namespace Id

Expand Down
4 changes: 2 additions & 2 deletions src/Init/Control/Lawful/MonadLift/Instances.lean
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ namespace StateRefT'
instance {ω σ : Type} {m : Type → Type} [Monad m] : LawfulMonadLift m (StateRefT' ω σ m) where
monadLift_pure _ := by
simp only [MonadLift.monadLift, pure]
unfold StateRefT'.lift instMonad._aux_5 ReaderT.pure
unfold StateRefT'.lift ReaderT.pure
simp only
monadLift_bind _ _ := by
simp only [MonadLift.monadLift, bind]
unfold StateRefT'.lift instMonad._aux_13 ReaderT.bind
unfold StateRefT'.lift ReaderT.bind
simp only

end StateRefT'
Expand Down
2 changes: 1 addition & 1 deletion src/Init/Control/Option.lean
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ instance : ToBool (Option α) := ⟨Option.isSome⟩
Adds the ability to fail to a monad. Unlike ordinary exceptions, there is no way to signal why a
failure occurred.
-/
@[expose] def OptionT (m : Type u → Type v) (α : Type u) : Type v :=
@[expose, implicit_reducible] def OptionT (m : Type u → Type v) (α : Type u) : Type v :=
m (Option α)

/--
Expand Down
2 changes: 1 addition & 1 deletion src/Init/Control/State.lean
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Adds a mutable state of type `σ` to a monad.
Actions in the resulting monad are functions that take an initial state and return, in `m`, a tuple
of a value and a state.
-/
@[expose] def StateT (σ : Type u) (m : Type u → Type v) (α : Type u) : Type (max u v) :=
@[expose, implicit_reducible] def StateT (σ : Type u) (m : Type u → Type v) (α : Type u) : Type (max u v) :=
σ → m (α × σ)

/--
Expand Down
2 changes: 1 addition & 1 deletion src/Init/Control/StateCps.lean
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The State monad transformer using CPS style.
An alternative implementation of a state monad transformer that internally uses continuation passing
style instead of tuples.
-/
@[expose] def StateCpsT (σ : Type u) (m : Type u → Type v) (α : Type u) := (δ : Type u) → σ → (α → σ → m δ) → m δ
@[expose, implicit_reducible] def StateCpsT (σ : Type u) (m : Type u → Type v) (α : Type u) := (δ : Type u) → σ → (α → σ → m δ) → m δ

namespace StateCpsT

Expand Down
2 changes: 1 addition & 1 deletion src/Init/Control/StateRef.lean
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ A state monad that uses an actual mutable reference cell (i.e. an `ST.Ref ω σ`

The macro `StateRefT σ m α` infers `ω` from `m`. It should normally be used instead.
-/
@[expose] def StateRefT' (ω : Type) (σ : Type) (m : Type → Type) (α : Type) : Type := ReaderT (ST.Ref ω σ) m α
@[expose, instance_reducible] def StateRefT' (ω : Type) (σ : Type) (m : Type → Type) (α : Type) : Type := ReaderT (ST.Ref ω σ) m α

/-! Recall that `StateRefT` is a macro that infers `ω` from the `m`. -/

Expand Down
7 changes: 4 additions & 3 deletions src/Init/Core.lean
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ the `BEq` typeclass.
Unlike `x ≠ y` (which is notation for `Ne x y`), this is `Bool` valued instead of
`Prop` valued. It is mainly intended for programming applications.
-/
@[inline] def bne {α : Type u} [BEq α] (a b : α) : Bool :=
@[inline, implicit_reducible] def bne {α : Type u} [BEq α] (a b : α) : Bool :=
!(a == b)

@[inherit_doc] infix:50 " != " => bne
Expand Down Expand Up @@ -1331,7 +1331,7 @@ def Subrelation {α : Sort u} (q r : α → α → Prop) :=
The inverse image of `r : β → β → Prop` by a function `α → β` is the relation
`s : α → α → Prop` defined by `s a b = r (f a) (f b)`.
-/
def InvImage {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β) : α → α → Prop :=
@[implicit_reducible] def InvImage {α : Sort u} {β : Sort v} (r : β → β → Prop) (f : α → β) : α → α → Prop :=
fun a₁ a₂ => r (f a₁) (f a₂)

/--
Expand Down Expand Up @@ -1478,7 +1478,7 @@ Examples:
* `(1, 2).map (· + 1) (· * 3) = (2, 6)`
* `(1, 2).map toString (· * 3) = ("1", 6)`
-/
def Prod.map {α₁ : Type u₁} {α₂ : Type u₂} {β₁ : Type v₁} {β₂ : Type v₂}
@[implicit_reducible] def Prod.map {α₁ : Type u₁} {α₂ : Type u₂} {β₁ : Type v₁} {β₂ : Type v₂}
(f : α₁ → α₂) (g : β₁ → β₂) : α₁ × β₁ → α₂ × β₂
| (a, b) => (f a, g b)

Expand Down Expand Up @@ -1983,6 +1983,7 @@ must respect `s.r`. `Quotient.lift` allows values in a quotient to be mapped to
as the mapping respects `s.r`.

-/
@[implicit_reducible]
protected def mk' {α : Sort u} [s : Setoid α] (a : α) : Quotient s :=
Quotient.mk s a

Expand Down
4 changes: 4 additions & 0 deletions src/Init/Data/Array/Attach.lean
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ theorem pmap_eq_map_attach {p : α → Prop} {f : ∀ a, p a → β} {xs : Array
cases xs
simp [List.pmap_eq_map_attach]

theorem attachWith_eq_map_attach {xs : Array α} {P : α → Prop} {H : ∀ (a : α), a ∈ xs → P a} :
xs.attachWith P H = xs.attach.map fun ⟨x, h⟩ => ⟨x, H _ h⟩ := by
cases xs <;> simp_all [List.attachWith_eq_map_attach]

@[simp]
theorem pmap_eq_attachWith {p q : α → Prop} {f : ∀ a, p a → q a} {xs : Array α} (H) :
pmap (fun a h => ⟨a, f a h⟩) xs H = xs.attachWith q (fun x h => f x (H x h)) := by
Expand Down
9 changes: 6 additions & 3 deletions src/Init/Data/Array/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ theorem ext' {xs ys : Array α} (h : xs.toList = ys.toList) : xs = ys := by

@[simp, grind =] theorem toArray_toList {xs : Array α} : xs.toList.toArray = xs := rfl

@[simp, grind =] theorem getElem_toList {xs : Array α} {i : Nat} (h : i < xs.size) : xs.toList[i] = xs[i] := rfl
-- TODO: Ideally we'd use `xs[i]'(id h)` to avoid defeq abuse, but then
-- `simp only [← getElem_toList]` won't work. For now, the solution is to make `Array.size`
-- implicit-reducible.
@[simp, grind =] theorem getElem_toList {xs : Array α} {i : Nat} (h : i < xs.toList.length) : xs.toList[i] = xs[i] := rfl

@[simp, grind =] theorem getElem?_toList {xs : Array α} {i : Nat} : xs.toList[i]? = xs[i]? := by
simp only [getElem?_def, getElem_toList]
Expand Down Expand Up @@ -170,7 +173,7 @@ Low-level indexing operator which is as fast as a C array read.

This avoids overhead due to unboxing a `Nat` used as an index.
-/
@[extern "lean_array_uget", simp, expose]
@[extern "lean_array_uget", simp, expose, implicit_reducible]
def uget (xs : @& Array α) (i : USize) (h : i.toNat < xs.size) : α :=
xs[i.toNat]

Expand All @@ -189,7 +192,7 @@ in-place when the reference to the array is unique.

This avoids overhead due to unboxing a `Nat` used as an index.
-/
@[extern "lean_array_uset", expose]
@[extern "lean_array_uset", expose, implicit_reducible]
def uset (xs : Array α) (i : USize) (v : α) (h : i.toNat < xs.size) : Array α :=
xs.set i.toNat v h

Expand Down
2 changes: 2 additions & 0 deletions src/Init/Data/Array/DecidableEq.lean
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ theorem isEqv_eq_decide (xs ys : Array α) (r) :
simpa [isEqv_iff_rel] using h'

@[simp, grind =] theorem isEqv_toList [BEq α] (xs ys : Array α) : (xs.toList.isEqv ys.toList r) = (xs.isEqv ys r) := by
-- rfl is necessary because `Array.getInternal isn't instance-reducible
simp [isEqv_eq_decide, List.isEqv_eq_decide, Array.size]; rfl

theorem eq_of_isEqv [DecidableEq α] (xs ys : Array α) (h : Array.isEqv xs ys (fun x y => x = y)) : xs = ys := by
Expand Down Expand Up @@ -154,6 +155,7 @@ theorem beq_eq_decide [BEq α] (xs ys : Array α) :
simp [BEq.beq, isEqv_eq_decide]

@[simp, grind =] theorem beq_toList [BEq α] (xs ys : Array α) : (xs.toList == ys.toList) = (xs == ys) := by
-- rfl is necessary because `Array.getInternal isn't instance-reducible
simp [beq_eq_decide, List.beq_eq_decide, Array.size]; rfl

end Array
Expand Down
2 changes: 1 addition & 1 deletion src/Init/Data/Array/FinRange.lean
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Examples:
* `Array.finRange 0 = (#[] : Array (Fin 0))`
* `Array.finRange 2 = (#[0, 1] : Array (Fin 2))`
-/
protected def finRange (n : Nat) : Array (Fin n) := ofFn fun i => i
@[expose, instance_reducible] protected def finRange (n : Nat) : Array (Fin n) := ofFn fun i => i

@[simp, grind =] theorem size_finRange {n} : (Array.finRange n).size = n := by
simp [Array.finRange]
Expand Down
7 changes: 3 additions & 4 deletions src/Init/Data/Array/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,7 @@ theorem getElem_of_append {xs ys zs : Array α} (eq : xs = ys.push a ++ zs) (h :
rw [← getElem?_eq_getElem, eq, getElem?_append_left (by simp; omega), ← h]
simp

@[simp] theorem append_singleton {a : α} {as : Array α} : as ++ #[a] = as.push a := rfl
@[simp] theorem append_singleton {a : α} {as : Array α} : as ++ #[a] = as.push a := (rfl)

@[simp] theorem append_singleton_assoc {a : α} {xs ys : Array α} : xs ++ (#[a] ++ ys) = xs.push a ++ ys := by
rw [← append_assoc, append_singleton]
Expand Down Expand Up @@ -2833,9 +2833,8 @@ theorem getElem_extract_aux {xs : Array α} {start stop : Nat} (h : i < (xs.extr

@[simp, grind =] theorem getElem_extract {xs : Array α} {start stop : Nat}
(h : i < (xs.extract start stop).size) :
(xs.extract start stop)[i] = xs[start + i]'(getElem_extract_aux h) :=
show (extract.loop xs (min stop xs.size - start) start #[])[i]
= xs[start + i]'(getElem_extract_aux h) by rw [getElem_extract_loop_ge]; rfl; exact Nat.zero_le _
(xs.extract start stop)[i] = xs[start + i]'(getElem_extract_aux h) := by
simp [extract, getElem_extract_loop_ge]

theorem getElem?_extract {xs : Array α} {start stop : Nat} :
(xs.extract start stop)[i]? = if i < min stop xs.size - start then xs[start + i]? else none := by
Expand Down
Loading
Loading