Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion src/Init/BinderNameHint.lean
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ This gadget is supported by
It is ineffective in other positions (hypotheses of rewrite rules) or when used by other tactics
(e.g. `apply`).
-/
@[simp ↓, expose, implicit_reducible]
@[simp ↓, expose, instance_reducible]
def binderNameHint {α : Sort u} {β : Sort v} {γ : Sort w} (v : α) (binder : β) (e : γ) : γ := e
8 changes: 4 additions & 4 deletions src/Init/Classical.lean
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ theorem em (p : Prop) : p ∨ ¬p :=
theorem exists_true_of_nonempty {α : Sort u} : Nonempty α → ∃ _ : α, True
| ⟨x⟩ => ⟨x, trivial⟩

@[implicit_reducible]
@[instance_reducible]
noncomputable def inhabited_of_nonempty {α : Sort u} (h : Nonempty α) : Inhabited α :=
⟨choice h⟩

@[implicit_reducible]
@[instance_reducible]
noncomputable def inhabited_of_exists {α : Sort u} {p : α → Prop} (h : ∃ x, p x) : Inhabited α :=
inhabited_of_nonempty (Exists.elim h (fun w _ => ⟨w⟩))

Expand All @@ -83,7 +83,7 @@ noncomputable scoped instance (priority := low) propDecidable (a : Prop) : Decid
| Or.inl h => ⟨isTrue h⟩
| Or.inr h => ⟨isFalse h⟩

@[implicit_reducible]
@[instance_reducible]
noncomputable def decidableInhabited (a : Prop) : Inhabited (Decidable a) where
default := inferInstance

Expand Down Expand Up @@ -145,7 +145,7 @@ is classically true but not constructively. -/

/-- Transfer decidability of `¬ p` to decidability of `p`. -/
-- This can not be an instance as it would be tried everywhere.
@[implicit_reducible]
@[instance_reducible]
def decidable_of_decidable_not (p : Prop) [h : Decidable (¬ p)] : Decidable p :=
match h with
| isFalse h => isTrue (Classical.not_not.mp h)
Expand Down
4 changes: 2 additions & 2 deletions src/Init/Control/Id.lean
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ instance : Monad Id where
/--
The identity monad has a `bind` operator.
-/
@[implicit_reducible]
@[instance_reducible]
def hasBind : Bind Id :=
inferInstance

Expand All @@ -59,7 +59,7 @@ Runs a computation in the identity monad.
This function is the identity function. Because its parameter has type `Id α`, it causes
`do`-notation in its arguments to use the `Monad Id` instance.
-/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
protected def run (x : Id α) : α := x

instance [OfNat α n] : OfNat (Id α) n :=
Expand Down
2 changes: 1 addition & 1 deletion src/Init/Control/MonadAttach.lean
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ information to the return value, except a trivial proof of {name}`True`.
This instance is used whenever no more useful {name}`MonadAttach` instance can be implemented.
It always has a {name}`WeaklyLawfulMonadAttach`, but usually no {name}`LawfulMonadAttach` instance.
-/
@[expose, implicit_reducible]
@[expose, instance_reducible]
public protected def MonadAttach.trivial {m : Type u → Type v} [Monad m] : MonadAttach m where
CanReturn _ _ := True
attach x := (⟨·, .intro⟩) <$> x
Expand Down
4 changes: 2 additions & 2 deletions src/Init/Data/Bool.lean
Original file line number Diff line number Diff line change
Expand Up @@ -629,15 +629,15 @@ export Bool (cond_eq_if cond_eq_ite xor and or not)
This should not be turned on globally as an instance because it degrades performance in Mathlib,
but may be used locally.
-/
@[implicit_reducible]
@[instance_reducible]
def boolPredToPred : Coe (α → Bool) (α → Prop) where
coe r := fun a => Eq (r a) true

/--
This should not be turned on globally as an instance because it degrades performance in Mathlib,
but may be used locally.
-/
@[expose, implicit_reducible] def boolRelToRel : Coe (α → α → Bool) (α → α → Prop) where
@[expose, instance_reducible] def boolRelToRel : Coe (α → α → Bool) (α → α → Prop) where
coe r := fun a b => Eq (r a b) true

/-! ### subtypes -/
Expand Down
2 changes: 1 addition & 1 deletion src/Init/Data/Char/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ instance ltTrans : Trans (· < · : Char → Char → Prop) (· < ·) (· < ·)
trans := Char.lt_trans

-- This instance is useful while setting up instances for `String`.
@[implicit_reducible]
@[instance_reducible]
def notLTTrans : Trans (¬ · < · : Char → Char → Prop) (¬ · < ·) (¬ · < ·) where
trans h₁ h₂ := by simpa using Char.le_trans (by simpa using h₂) (by simpa using h₁)

Expand Down
4 changes: 2 additions & 2 deletions src/Init/Data/Fin/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ For example, for `x : Fin k` and `n : Nat`,
it causes `x < n` to be elaborated as `x < ↑n` rather than `↑x < n`,
silently introducing wraparound arithmetic.
-/
@[implicit_reducible]
@[instance_reducible]
def instNatCast (n : Nat) [NeZero n] : NatCast (Fin n) where
natCast a := Fin.ofNat n a

Expand All @@ -144,7 +144,7 @@ This is not a global instance, but may be activated locally via `open Fin.IntCas

See the doc-string for `Fin.NatCast.instNatCast` for more details.
-/
@[implicit_reducible]
@[instance_reducible]
def instIntCast (n : Nat) [NeZero n] : IntCast (Fin n) where
intCast := Fin.intCast

Expand Down
6 changes: 3 additions & 3 deletions src/Init/Data/Iterators/Consumers/Loop.lean
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ A `ForIn'` instance for iterators. Its generic membership relation is not easy t
so this is not marked as `instance`. This way, more convenient instances can be built on top of it
or future library improvements will make it more comfortable.
-/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def Iter.instForIn' {α : Type w} {β : Type w} {n : Type x → Type x'} [Monad n]
[Iterator α Id β] [IteratorLoop α Id n] :
ForIn' n (Iter (α := α) β) β ⟨fun it out => it.IsPlausibleIndirectOutput out⟩ where
Expand All @@ -53,7 +53,7 @@ instance (α : Type w) (β : Type w) (n : Type x → Type x') [Monad n]
/--
An implementation of `for h : ... in ... do ...` notation for partial iterators.
-/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def Iter.Partial.instForIn' {α : Type w} {β : Type w} {n : Type x → Type x'} [Monad n]
[Iterator α Id β] [IteratorLoop α Id n] :
ForIn' n (Iter.Partial (α := α) β) β ⟨fun it out => it.it.IsPlausibleIndirectOutput out⟩ where
Expand All @@ -71,7 +71,7 @@ instance (α : Type w) (β : Type w) (n : Type x → Type x') [Monad n]
A `ForIn'` instance for iterators that is guaranteed to terminate after finitely many steps.
It is not marked as an instance because the membership predicate is difficult to work with.
-/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def Iter.Total.instForIn' {α : Type w} {β : Type w} {n : Type x → Type x'} [Monad n]
[Iterator α Id β] [IteratorLoop α Id n] [Finite α Id] :
ForIn' n (Iter.Total (α := α) β) β ⟨fun it out => it.it.IsPlausibleIndirectOutput out⟩ where
Expand Down
10 changes: 5 additions & 5 deletions src/Init/Data/Iterators/Consumers/Monadic/Loop.lean
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ This is the default implementation of the `IteratorLoop` class.
It simply iterates through the iterator using `IterM.step`. For certain iterators, more efficient
implementations are possible and should be used instead.
-/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def IteratorLoop.defaultImplementation {α : Type w} {m : Type w → Type w'} {n : Type x → Type x'}
[Monad n] [Iterator α m β] :
IteratorLoop α m n where
Expand Down Expand Up @@ -211,7 +211,7 @@ theorem IteratorLoop.wellFounded_of_productive {α β : Type w} {m : Type w →
/--
This `ForIn'`-style loop construct traverses a finite iterator using an `IteratorLoop` instance.
-/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def IteratorLoop.finiteForIn' {m : Type w → Type w'} {n : Type x → Type x'}
{α : Type w} {β : Type w} [Iterator α m β] [IteratorLoop α m n] [Monad n]
(lift : ∀ γ δ, (γ → n δ) → m γ → n δ) :
Expand All @@ -224,7 +224,7 @@ A `ForIn'` instance for iterators. Its generic membership relation is not easy t
so this is not marked as `instance`. This way, more convenient instances can be built on top of it
or future library improvements will make it more comfortable.
-/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def IterM.instForIn' {m : Type w → Type w'} {n : Type w → Type w''}
{α : Type w} {β : Type w} [Iterator α m β] [IteratorLoop α m n] [Monad n]
[MonadLiftT m n] :
Expand All @@ -239,15 +239,15 @@ instance IterM.instForInOfIteratorLoop {m : Type w → Type w'} {n : Type w →
instForInOfForIn'

/-- Internal implementation detail of the iterator library. -/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def IterM.Partial.instForIn' {m : Type w → Type w'} {n : Type w → Type w''}
{α : Type w} {β : Type w} [Iterator α m β] [IteratorLoop α m n] [MonadLiftT m n] [Monad n] :
ForIn' n (IterM.Partial (α := α) m β) β ⟨fun it out => it.it.IsPlausibleIndirectOutput out⟩ where
forIn' it init f :=
haveI := @IterM.instForIn'; forIn' it.it init f

/-- Internal implementation detail of the iterator library. -/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def IterM.Total.instForIn' {m : Type w → Type w'} {n : Type w → Type w''}
{α : Type w} {β : Type w} [Iterator α m β] [IteratorLoop α m n] [MonadLiftT m n] [Monad n]
[Finite α m] :
Expand Down
4 changes: 2 additions & 2 deletions src/Init/Data/Iterators/ToIterator.lean
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def ToIterator.iter [ToIterator γ Id α β] (x : γ) : Iter (α := α) β :=
ToIterator.iterM x |>.toIter

/-- Creates a monadic `ToIterator` instance. -/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def ToIterator.ofM (α : Type w)
(iterM : γ → IterM (α := α) m β) :
ToIterator γ m α β where
iterMInternal x := iterM x

/-- Creates a pure `ToIterator` instance. -/
@[always_inline, inline, expose, implicit_reducible]
@[always_inline, inline, expose, instance_reducible]
def ToIterator.of (α : Type w)
(iter : γ → Iter (α := α) β) :
ToIterator γ Id α β where
Expand Down
14 changes: 7 additions & 7 deletions src/Init/Data/Ord/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -619,22 +619,22 @@ protected theorem compare_nil_right_eq_eq {α} [Ord α] {xs : List α} :
end List

/-- The lexicographic order on pairs. -/
@[expose, implicit_reducible]
@[expose, instance_reducible]
def lexOrd [Ord α] [Ord β] : Ord (α × β) where
compare := compareLex (compareOn (·.1)) (compareOn (·.2))

/--
Constructs an `BEq` instance from an `Ord` instance that asserts that the result of `compare` is
`Ordering.eq`.
-/
@[expose, implicit_reducible] def beqOfOrd [Ord α] : BEq α where
@[expose, instance_reducible] def beqOfOrd [Ord α] : BEq α where
beq a b := (compare a b).isEq

/--
Constructs an `LT` instance from an `Ord` instance that asserts that the result of `compare` is
`Ordering.lt`.
-/
@[expose, implicit_reducible] def ltOfOrd [Ord α] : LT α where
@[expose, instance_reducible] def ltOfOrd [Ord α] : LT α where
lt a b := compare a b = Ordering.lt

@[inline]
Expand All @@ -645,7 +645,7 @@ instance [Ord α] : DecidableRel (@LT.lt α ltOfOrd) := fun a b =>
Constructs an `LE` instance from an `Ord` instance that asserts that the result of `compare`
satisfies `Ordering.isLE`.
-/
@[expose, implicit_reducible] def leOfOrd [Ord α] : LE α where
@[expose, instance_reducible] def leOfOrd [Ord α] : LE α where
le a b := (compare a b).isLE

@[inline]
Expand Down Expand Up @@ -677,7 +677,7 @@ Inverts the order of an `Ord` instance.
The result is an `Ord α` instance that returns `Ordering.lt` when `ord` would return `Ordering.gt`
and that returns `Ordering.gt` when `ord` would return `Ordering.lt`.
-/
@[expose, implicit_reducible] protected def opposite (ord : Ord α) : Ord α where
@[expose, instance_reducible] protected def opposite (ord : Ord α) : Ord α where
compare x y := ord.compare y x

/--
Expand All @@ -688,7 +688,7 @@ In particular, `ord.on f` compares `x` and `y` by comparing `f x` and `f y` acco
The function `compareOn` can be used to perform this comparison without constructing an intermediate
`Ord` instance.
-/
@[expose, implicit_reducible] protected def on (_ : Ord β) (f : α → β) : Ord α where
@[expose, instance_reducible] protected def on (_ : Ord β) (f : α → β) : Ord α where
compare := compareOn f

/--
Expand All @@ -707,7 +707,7 @@ The function `compareLex` can be used to perform this comparison without constru
intermediate `Ord` instance. `Ordering.then` can be used to lexicographically combine the results of
comparisons.
-/
@[expose, implicit_reducible] protected def lex' (ord₁ ord₂ : Ord α) : Ord α where
@[expose, instance_reducible] protected def lex' (ord₁ ord₂ : Ord α) : Ord α where
compare := compareLex ord₁.compare ord₂.compare

end Ord
6 changes: 3 additions & 3 deletions src/Init/Data/Order/Factories.lean
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ preferring `a` over `b` when in doubt.

Has a `LawfulOrderLeftLeaningMin α` instance.
-/
@[inline, implicit_reducible]
@[inline, instance_reducible]
public def _root_.Min.leftLeaningOfLE (α : Type u) [LE α] [DecidableLE α] : Min α where
min a b := if a ≤ b then a else b

Expand All @@ -33,7 +33,7 @@ preferring `a` over `b` when in doubt.

Has a `LawfulOrderLeftLeaningMax α` instance.
-/
@[inline, implicit_reducible]
@[inline, instance_reducible]
public def _root_.Max.leftLeaningOfLE (α : Type u) [LE α] [DecidableLE α] : Max α where
max a b := if b ≤ a then a else b

Expand Down Expand Up @@ -196,7 +196,7 @@ Creates a *total* `LE α` instance from an `LT α` instance.

This only makes sense for asymmetric `LT α` instances (see `Std.Asymm`).
-/
@[inline, implicit_reducible, expose]
@[inline, instance_reducible, expose]
public def _root_.LE.ofLT (α : Type u) [LT α] : LE α where
le a b := ¬ b < a

Expand Down
10 changes: 5 additions & 5 deletions src/Init/Data/Order/FactoriesExtra.lean
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ Creates an `LE α` instance from an `Ord α` instance.
`OrientedOrd α` must be satisfied so that the resulting `LE α` instance faithfully represents
the `Ord α` instance.
-/
@[inline, expose, implicit_reducible]
@[inline, expose, instance_reducible]
public def _root_.LE.ofOrd (α : Type u) [Ord α] : LE α where
le a b := (compare a b).isLE

/--
Creates an `DecidableLE α` instance using a well-behaved `Ord α` instance.
-/
@[inline, expose, implicit_reducible]
@[inline, expose, instance_reducible]
public def _root_.DecidableLE.ofOrd (α : Type u) [LE α] [Ord α] [LawfulOrderOrd α] :
DecidableLE α :=
fun a b => match h : (compare a b).isLE with
Expand All @@ -39,7 +39,7 @@ Creates an `LT α` instance from an `Ord α` instance.
`OrientedOrd α` must be satisfied so that the resulting `LT α` instance faithfully represents
the `Ord α` instance.
-/
@[inline, expose, implicit_reducible]
@[inline, expose, instance_reducible]
public def _root_.LT.ofOrd (α : Type u) [Ord α] :
LT α where
lt a b := compare a b = .lt
Expand Down Expand Up @@ -93,7 +93,7 @@ grind_pattern compare_ne_eq => compare a b, Ordering.eq where
/--
Creates a `DecidableLT α` instance using a well-behaved `Ord α` instance.
-/
@[inline, expose, implicit_reducible]
@[inline, expose, instance_reducible]
public def _root_.DecidableLT.ofOrd (α : Type u) [LE α] [LT α] [Ord α] [LawfulOrderOrd α]
[LawfulOrderLT α] :
DecidableLT α :=
Expand All @@ -104,7 +104,7 @@ public def _root_.DecidableLT.ofOrd (α : Type u) [LE α] [LT α] [Ord α] [Lawf

/--
Creates a `BEq α` instance from an `Ord α` instance. -/
@[inline, expose, implicit_reducible]
@[inline, expose, instance_reducible]
public def _root_.BEq.ofOrd (α : Type u) [Ord α] :
BEq α where
beq a b := compare a b = .eq
Expand Down
8 changes: 4 additions & 4 deletions src/Init/Data/Order/Opposite.lean
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def max' [LE α] [DecidableLE α] (a b : α) : α :=
Without the `open scoped` command, Lean would not find the required {lit}`DecidableLE α`
instance for the opposite order.
-/
@[implicit_reducible]
@[instance_reducible]
def LE.opposite (le : LE α) : LE α where
le a b := b ≤ a

Expand Down Expand Up @@ -90,7 +90,7 @@ example [LE α] [LT α] [Std.LawfulOrderLT α] [Std.IsLinearOrder α] {x y : α}
Without the `open scoped` command, Lean would not find the {lit}`LawfulOrderLT α`
and {lit}`IsLinearOrder α` instances for the opposite order that are required by {name}`not_le`.
-/
@[implicit_reducible]
@[instance_reducible]
def LT.opposite (lt : LT α) : LT α where
lt a b := b < a

Expand Down Expand Up @@ -127,7 +127,7 @@ example [LE α] [DecidableLE α] [Min α] [Std.LawfulOrderLeftLeaningMin α] {a
Without the `open scoped` command, Lean would not find the {lit}`LawfulOrderLeftLeaningMax α`
instance for the opposite order that is required by {name}`max_eq_if`.
-/
@[implicit_reducible]
@[instance_reducible]
def Min.oppositeMax (min : Min α) : Max α where
max a b := Min.min a b

Expand Down Expand Up @@ -164,7 +164,7 @@ example [LE α] [DecidableLE α] [Max α] [Std.LawfulOrderLeftLeaningMax α] {a
Without the `open scoped` command, Lean would not find the {lit}`LawfulOrderLeftLeaningMin α`
instance for the opposite order that is required by {name}`min_eq_if`.
-/
@[implicit_reducible]
@[instance_reducible]
def Max.oppositeMin (max : Max α) : Min α where
min a b := Max.max a b

Expand Down
Loading
Loading