Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e17bb1d
chore: add implicit_reducible/expose attributes to preparatory defini…
leodemoura Apr 4, 2026
51a0b95
test: update tests for defeq changes
leodemoura Apr 4, 2026
b58079c
chore: add implicit_reducible/expose attributes to library definitions
leodemoura Apr 5, 2026
8b9c0c3
feat: enable `backward.isDefEq.respectTransparency.types` by default
leodemoura Apr 5, 2026
7a7cba2
test: update tests for defeq changes
leodemoura Apr 5, 2026
35500a6
fix: add `Option.map_some` to `modify_eq_alter` simp sets
kim-em Apr 30, 2026
415eb53
fix: remove @[expose] when unnecessary, fixing stage2 warnings in #13…
datokrat May 4, 2026
9bcba38
fix errors from rebasing
datokrat May 7, 2026
a7cf03f
remove respectTransparency.types false
TwoFX Apr 7, 2026
d913d67
remove local attributes
datokrat May 7, 2026
e279d46
cleanup
datokrat May 7, 2026
fd23f9e
dsimproc test
datokrat May 8, 2026
14433ea
snapshot
datokrat May 8, 2026
d74fd4a
Revert "snapshot"
datokrat May 8, 2026
987c895
remove test files; I gave up trying to satisfy the dsimprocs for now
datokrat May 8, 2026
f837ebf
Revert "remove test files; I gave up trying to satisfy the dsimprocs …
datokrat May 12, 2026
da6cfcf
implicit -> instance
datokrat May 12, 2026
8b0cae4
Reapply "snapshot"
datokrat May 12, 2026
4f9f5f9
poke
datokrat May 12, 2026
0123e20
it compiles
datokrat May 12, 2026
1b2b5a8
linter
datokrat May 16, 2026
e8c40db
make Not implicit_reducible
datokrat May 23, 2026
ca8df66
experiment: always check types for instance metavariables at instance…
TwoFX May 25, 2026
9036da0
fixes
TwoFX May 26, 2026
9e14e20
Introduct option
TwoFX May 26, 2026
5c6566f
feat: trace transparency level in `Meta.isDefEq`
kim-em May 18, 2026
703cf7d
experiment: do not bump transparency when assigning `outParam`s
TwoFX May 27, 2026
32ec89a
experiment: fix `inferInstanceAs` elaborator
TwoFX May 27, 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 :=
@[instance_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, instance_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, instance_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, instance_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, instance_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
6 changes: 3 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 :=
@[instance_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₂}
@[instance_reducible] def Prod.map {α₁ : Type u₁} {α₂ : Type u₂} {β₁ : Type v₁} {β₂ : Type v₂}
(f : α₁ → α₂) (g : β₁ → β₂) : α₁ × β₁ → α₂ × β₂
| (a, b) => (f a, g b)

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
4 changes: 2 additions & 2 deletions src/Init/Data/Array/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,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, instance_reducible]
def uget (xs : @& Array α) (i : USize) (h : i.toNat < xs.size) : α :=
xs[i.toNat]

Expand All @@ -189,7 +189,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, instance_reducible]
def uset (xs : Array α) (i : USize) (v : α) (h : i.toNat < xs.size) : Array α :=
xs.set i.toNat v h

Expand Down
4 changes: 2 additions & 2 deletions src/Init/Data/Array/DecidableEq.lean
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +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
simp [isEqv_eq_decide, List.isEqv_eq_decide, Array.size]; rfl
simp [isEqv_eq_decide, List.isEqv_eq_decide, Array.size]

theorem eq_of_isEqv [DecidableEq α] (xs ys : Array α) (h : Array.isEqv xs ys (fun x y => x = y)) : xs = ys := by
have ⟨h, h'⟩ := rel_of_isEqv h
Expand Down Expand Up @@ -154,7 +154,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
simp [beq_eq_decide, List.beq_eq_decide, Array.size]; rfl
simp [beq_eq_decide, List.beq_eq_decide, Array.size]

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