Skip to content

Commit aff21ab

Browse files
committed
chore(Order/Defs/Unbundled): deprecate def Reflexive in favor of class Std.Refl (#37278)
Also adds definitional lemmas `std*_def` for the relation classes, and cleans up things nearby, especially in `Logic/Relation.lean`.
1 parent c8f5859 commit aff21ab

20 files changed

Lines changed: 229 additions & 171 deletions

File tree

Mathlib/Algebra/Group/Semiconj/Defs.lean

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ theorem one_left (x : M) : SemiconjBy 1 x x :=
9999
generally, on `MulOneClass` type) is reflexive. -/
100100
@[to_additive /-- The relation “there exists an element that semiconjugates `a` to `b`” on an
101101
additive monoid (or, more generally, on an `AddZeroClass` type) is reflexive. -/]
102-
protected theorem reflexive : Reflexive fun a b : M ↦ ∃ c, SemiconjBy c a b
103-
| a => ⟨1, one_left a⟩
102+
protected theorem refl : Std.Refl fun a b : M ↦ ∃ c, SemiconjBy c a b where
103+
refl a := ⟨1, one_left a⟩
104+
105+
@[deprecated (since := "2026-03-27")] protected alias reflexive := SemiconjBy.refl
104106

105107
end MulOneClass
106108

Mathlib/CategoryTheory/Abelian/Pseudoelements.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ theorem app_hom {P Q : C} (f : P ⟶ Q) (a : Over P) : (app f a).hom = a.hom ≫
106106
def PseudoEqual (P : C) (f g : Over P) : Prop :=
107107
∃ (R : C) (p : R ⟶ f.1) (q : R ⟶ g.1) (_ : Epi p) (_ : Epi q), p ≫ f.hom = q ≫ g.hom
108108

109-
theorem pseudoEqual_refl {P : C} : Reflexive (PseudoEqual P) :=
110-
fun f => ⟨f.1, 𝟙 f.1, 𝟙 f.1, inferInstance, inferInstance, by simp⟩
109+
theorem pseudoEqual_refl {P : C} : Std.Refl (PseudoEqual P) where
110+
refl f := ⟨f.1, 𝟙 f.1, 𝟙 f.1, inferInstance, inferInstance, by simp⟩
111111

112112
theorem pseudoEqual_symm {P : C} : Symmetric (PseudoEqual P) :=
113113
fun _ _ ⟨R, p, q, ep, Eq, comm⟩ => ⟨R, q, p, Eq, ep, comm.symm⟩
@@ -131,7 +131,7 @@ end
131131
/-- The arrows with codomain `P` equipped with the equivalence relation of being pseudo-equal. -/
132132
@[instance_reducible]
133133
def Pseudoelement.setoid (P : C) : Setoid (Over P) :=
134-
⟨_, ⟨pseudoEqual_refl, @pseudoEqual_symm _ _ _, pseudoEqual_trans.trans _ _ _⟩⟩
134+
⟨_, ⟨pseudoEqual_refl.refl, @pseudoEqual_symm _ _ _, pseudoEqual_trans.trans _ _ _⟩⟩
135135

136136
attribute [local instance] Pseudoelement.setoid
137137

Mathlib/CategoryTheory/IsConnected.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,7 @@ theorem zigzag_symmetric : Symmetric (@Zigzag J _) :=
315315
Relation.ReflTransGen.symmetric zag_symmetric
316316

317317
theorem zigzag_equivalence : _root_.Equivalence (@Zigzag J _) :=
318-
⟨Relation.reflexive_reflTransGen, (zigzag_symmetric ·),
319-
IsTrans.trans (r := Relation.ReflTransGen _) _ _ _⟩
318+
⟨refl_of <| Relation.ReflTransGen _, (zigzag_symmetric ·), trans_of <| Relation.ReflTransGen _⟩
320319

321320
@[refl] theorem Zigzag.refl (X : J) : Zigzag X X := zigzag_equivalence.refl _
322321

Mathlib/Computability/Reduce.lean

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ theorem ManyOneReducible.trans {α β γ} [Primcodable α] [Primcodable β] [Pri
5959
⟨g ∘ f, c₂.comp c₁,
6060
fun a => ⟨fun h => by rw [comp_apply, ← h₂, ← h₁]; assumption, fun h => by rwa [h₁, h₂]⟩⟩
6161

62-
theorem reflexive_manyOneReducible {α} [Primcodable α] : Reflexive (@ManyOneReducible α α _ _) :=
63-
manyOneReducible_refl
62+
instance stdRefl_manyOneReducible {α} [Primcodable α] : Std.Refl (@ManyOneReducible α α _ _) where
63+
refl := manyOneReducible_refl
6464

65-
theorem isTrans_manyOneReducible {α} [Primcodable α] : IsTrans (α → Prop) ManyOneReducible :=
66-
fun _ _ _ ↦ ManyOneReducible.trans⟩
65+
@[deprecated (since := "2026-03-27")] alias reflexive_manyOneReducible := stdRefl_manyOneReducible
66+
67+
instance isTrans_manyOneReducible {α} [Primcodable α] : IsTrans (α → Prop) ManyOneReducible where
68+
trans _ _ _ := ManyOneReducible.trans
6769

6870
@[deprecated (since := "2026-02-21")] alias transitive_manyOneReducible := isTrans_manyOneReducible
6971

@@ -104,11 +106,13 @@ theorem OneOneReducible.of_equiv_symm {α β} [Primcodable α] [Primcodable β]
104106
(q : β → Prop) (h : Computable e.symm) : q ≤₁ (q ∘ e) := by
105107
convert OneOneReducible.of_equiv _ h; funext; simp
106108

107-
theorem reflexive_oneOneReducible {α} [Primcodable α] : Reflexive (@OneOneReducible α α _ _) :=
108-
oneOneReducible_refl
109+
instance stdRefl_oneOneReducible {α} [Primcodable α] : Std.Refl (@OneOneReducible α α _ _) where
110+
refl := oneOneReducible_refl
111+
112+
@[deprecated (since := "2026-03-27")] alias reflexive_oneOneReducible := stdRefl_oneOneReducible
109113

110-
theorem isTrans_oneOneReducible {α} [Primcodable α] : IsTrans (α → Prop) OneOneReducible :=
111-
fun _ _ _ OneOneReducible.trans
114+
instance isTrans_oneOneReducible {α} [Primcodable α] : IsTrans (α → Prop) OneOneReducible where
115+
trans _ _ _ := OneOneReducible.trans
112116

113117
@[deprecated (since := "2026-02-21")] alias transitive_oneOneReducible := isTrans_oneOneReducible
114118

Mathlib/Data/List/Pairwise.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ theorem Pairwise.forall (hR : Symmetric R) (hl : l.Pairwise R) :
5454
theorem Pairwise.set_pairwise (hl : Pairwise R l) (hr : Symmetric R) : { x | x ∈ l }.Pairwise R :=
5555
hl.forall hr
5656

57-
theorem pairwise_of_reflexive_of_forall_ne (hr : Reflexive R)
58-
(h : ∀ a ∈ l, ∀ b ∈ l, a ≠ b → R a b) : l.Pairwise R := by
57+
theorem pairwise_of_reflexive_of_forall_ne [Std.Refl R] (h : ∀ a ∈ l, ∀ b ∈ l, a ≠ b → R a b) :
58+
l.Pairwise R := by
5959
rw [pairwise_iff_forall_sublist]
6060
intro a b hab
6161
if heq : a = b then
62-
cases heq; apply hr
62+
cases heq; apply refl
6363
else
6464
apply h <;> try (apply hab.subset; simp)
6565
exact heq

Mathlib/Data/Seq/Computation.lean

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,8 @@ theorem lift_eq_iff_equiv (c₁ c₂ : Computation α) : LiftRel (· = ·) c₁
880880
fun a2 => by let ⟨b, b1, ab⟩ := h2 a2; rwa [← ab]⟩,
881881
fun e => ⟨fun {a} a1 => ⟨a, (e _).1 a1, rfl⟩, fun {a} a2 => ⟨a, (e _).2 a2, rfl⟩⟩⟩
882882

883-
theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun _ =>
884-
fun {a} as => ⟨a, as, H a⟩, fun {b} bs => ⟨b, bs, H b⟩⟩
883+
instance LiftRel.refl (R : α → α → Prop) [Std.Refl R] : Std.Refl (LiftRel R) where
884+
refl _ := fun {a} as => ⟨a, as, refl_of R a⟩, fun {b} bs => ⟨b, bs, refl_of R b⟩⟩
885885

886886
theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=
887887
fun _ _ ⟨l, r⟩ =>
@@ -892,19 +892,21 @@ theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (Lif
892892
let ⟨b, b2, ab⟩ := l a1
893893
⟨b, b2, H ab⟩⟩
894894

895-
theorem LiftRel.trans (R : α → α → Prop) (H : IsTrans α R) : IsTrans _ (LiftRel R) :=
895+
instance LiftRel.trans (R : α → α → Prop) [IsTrans α R] : IsTrans _ (LiftRel R) :=
896896
fun _ _ _ ⟨l1, r1⟩ ⟨l2, r2⟩ =>
897-
fun {a} a1 =>
898-
letb, b2, ab⟩ := l1 a1
897+
fun {_a} a1 =>
898+
let_b, b2, ab⟩ := l1 a1
899899
let ⟨c, c3, bc⟩ := l2 b2
900-
⟨c, c3, H.trans a b c ab bc⟩,
901-
fun {c} c3 =>
902-
letb, b2, bc⟩ := r2 c3
900+
⟨c, c3, trans_of R ab bc⟩,
901+
fun {_c} c3 =>
902+
let_b, b2, bc⟩ := r2 c3
903903
let ⟨a, a1, ab⟩ := r1 b2
904-
⟨a, a1, H.trans a b c ab bc⟩⟩⟩
904+
⟨a, a1, trans_of R ab bc⟩⟩⟩
905905

906-
theorem LiftRel.equiv (R : α → α → Prop) (H : Equivalence R) : Equivalence (LiftRel R) :=
907-
⟨LiftRel.refl R H.refl, @LiftRel.symm _ R @H.symm, LiftRel.trans R H.isTrans |>.trans _ _ _⟩
906+
theorem LiftRel.equiv (R : α → α → Prop) (H : Equivalence R) : Equivalence (LiftRel R) where
907+
refl := @LiftRel.refl α R H.stdRefl |>.refl
908+
symm := @LiftRel.symm α R H.symmetric
909+
trans := @LiftRel.trans α R H.isTrans |>.trans _ _ _
908910

909911
theorem LiftRel.imp {R S : α → β → Prop} (H : ∀ {a b}, R a b → S a b) (s t) :
910912
LiftRel R s t → LiftRel S s t

Mathlib/Data/Sym/Sym2.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -620,20 +620,19 @@ lemma diagSet_eq_fromRel_eq : diagSet = fromRel (α := α) eq_equivalence.symmet
620620
lemma diagSet_compl_eq_fromRel_ne : diagSetᶜ = fromRel (α := α) (r := Ne) (fun _ _ ↦ Ne.symm) := by
621621
ext ⟨a, b⟩; simp
622622

623-
@[simp] lemma diagSet_subset_fromRel (hr : Symmetric r) : diagSet ⊆ fromRel hr ↔ Reflexive r := by
624-
simp [Set.subset_def, Sym2.forall, Reflexive]
623+
@[simp] lemma diagSet_subset_fromRel (hr : Symmetric r) : diagSet ⊆ fromRel hr ↔ Std.Refl r := by
624+
simp [Set.subset_def, Sym2.forall, refl_def]
625625

626626
@[simp] lemma disjoint_diagSet_fromRel (hr : Symmetric r) :
627627
Disjoint diagSet (fromRel hr) ↔ Std.Irrefl r := by
628-
refine .trans ?_ ⟨(⟨·⟩), (·.irrefl)⟩
629-
simp [Set.disjoint_left, Sym2.forall]
628+
simp [Set.disjoint_left, Sym2.forall, irrefl_def]
630629

631630
@[simp] lemma fromRel_subset_compl_diagSet (hr : Symmetric r) :
632631
fromRel hr ⊆ diagSetᶜ ↔ Std.Irrefl r := by simp [Set.subset_compl_iff_disjoint_left]
633632

634633
@[deprecated diagSet_subset_fromRel (since := "2025-12-10")]
635634
theorem reflexive_iff_diagSet_subset_fromRel (sym : Symmetric r) :
636-
Reflexive r ↔ diagSet ⊆ fromRel sym := by simp
635+
Std.Refl r ↔ diagSet ⊆ fromRel sym := by simp
637636

638637
@[deprecated fromRel_subset_compl_diagSet (since := "2025-12-10")]
639638
theorem irreflexive_iff_fromRel_subset_diagSet_compl (sym : Symmetric r) :

Mathlib/Data/WSeq/Relation.lean

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,24 @@ theorem LiftRel.swap_lem {R : α → β → Prop} {s1 s2} (h : LiftRel R s1 s2)
104104
theorem LiftRel.swap (R : α → β → Prop) : swap (LiftRel R) = LiftRel (swap R) :=
105105
funext fun _ => funext fun _ => propext ⟨LiftRel.swap_lem, LiftRel.swap_lem⟩
106106

107-
theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun s => by
108-
refine ⟨(· = ·), rfl, fun {s t} (h : s = t) => ?_⟩
109-
rw [← h]
110-
apply Computation.LiftRel.refl
111-
intro a
112-
rcases a with - | a
113-
· simp
114-
· cases a
115-
simp only [LiftRelO, and_true]
116-
apply H
107+
instance LiftRelO.refl (R : α → α → Prop) [Std.Refl R] : Std.Refl <| LiftRelO R (· = ·) where
108+
refl a := by
109+
rcases a with - | a
110+
· simp
111+
· cases a
112+
simp only [LiftRelO, and_true]
113+
apply refl_of R
114+
115+
instance LiftRel.refl (R : α → α → Prop) [Std.Refl R] : Std.Refl (LiftRel R) where
116+
refl s := by
117+
refine ⟨(· = ·), rfl, fun {s t} (h : s = t) => ?_⟩
118+
rw [← h]
119+
apply Computation.LiftRel.refl _ |>.refl
117120

118121
theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) :=
119122
fun s1 s2 (h : Function.swap (LiftRel R) s2 s1) => by rwa [LiftRel.swap, H.swap_eq] at h
120123

121-
theorem LiftRel.trans (R : α → α → Prop) (H : IsTrans α R) : IsTrans _ (LiftRel R) := by
124+
instance LiftRel.trans (R : α → α → Prop) [IsTrans α R] : IsTrans _ (LiftRel R) := by
122125
refine ⟨fun s t u h1 h2 ↦ ?_⟩
123126
refine ⟨fun s u => ∃ t, LiftRel R s t ∧ LiftRel R t u, ⟨t, h1, h2⟩, fun {s u} h => ?_⟩
124127
rcases h with ⟨t, h1, h2⟩
@@ -147,10 +150,12 @@ theorem LiftRel.trans (R : α → α → Prop) (H : IsTrans α R) : IsTrans _ (L
147150
obtain ⟨c, u⟩ := c
148151
obtain ⟨ab, st⟩ := t1
149152
obtain ⟨bc, tu⟩ := t2
150-
exact ⟨H.trans a b c ab bc, t, st, tu⟩
153+
exact ⟨trans_of R ab bc, t, st, tu⟩
151154

152-
theorem LiftRel.equiv (R : α → α → Prop) (H : Equivalence R) : Equivalence (LiftRel R) :=
153-
⟨LiftRel.refl R H.refl, @(LiftRel.symm R @H.symm), LiftRel.trans R H.isTrans |>.trans _ _ _⟩
155+
theorem LiftRel.equiv (R : α → α → Prop) (H : Equivalence R) : Equivalence (LiftRel R) where
156+
refl := @LiftRel.refl α R H.stdRefl |>.refl
157+
symm := @LiftRel.symm α R H.symmetric
158+
trans := @LiftRel.trans α R H.isTrans |>.trans _ _ _
154159

155160
/-- If two sequences are equivalent, then they have the same values and
156161
the same computational behavior (i.e. if one loops forever then so does
@@ -163,15 +168,15 @@ def Equiv : WSeq α → WSeq α → Prop :=
163168

164169
@[refl]
165170
theorem Equiv.refl : ∀ s : WSeq α, s ~ʷ s :=
166-
LiftRel.refl (· = ·) Eq.refl
171+
LiftRel.refl (· = ·) |>.refl
167172

168173
@[symm]
169174
theorem Equiv.symm : ∀ {s t : WSeq α}, s ~ʷ t → t ~ʷ s :=
170175
@(LiftRel.symm (· = ·) (@Eq.symm _))
171176

172177
@[trans]
173178
theorem Equiv.trans : ∀ {s t u : WSeq α}, s ~ʷ t → t ~ʷ u → s ~ʷ u :=
174-
LiftRel.trans (· = ·) inferInstance |>.trans _ _ _
179+
LiftRel.trans (· = ·) |>.trans _ _ _
175180

176181
theorem Equiv.equivalence : Equivalence (@Equiv α) :=
177182
⟨@Equiv.refl _, @Equiv.symm _, @Equiv.trans _⟩

Mathlib/GroupTheory/FreeGroup/Basic.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ theorem Step.sublist (H : Red.Step L₁ L₂) : L₂ <+ L₁ := by
323323
protected theorem sublist : Red L₁ L₂ → L₂ <+ L₁ :=
324324
@reflTransGen_of_isTrans_reflexive
325325
_ (fun a b => b <+ a) _ _ _
326-
(fun l => List.Sublist.refl l)
326+
List.Sublist.refl
327327
fun _a _b _c hab hbc => List.Sublist.trans hbc hab⟩
328328
(fun _ _ => Red.Step.sublist)
329329

@@ -367,8 +367,9 @@ theorem equivalence_join_red : Equivalence (Join (@Red α)) :=
367367
| _, _, Or.inr ⟨d, hbd, hcd⟩ => ⟨d, ReflGen.single hbd, ReflTransGen.single hcd⟩
368368

369369
@[to_additive]
370-
theorem join_red_of_step (h : Red.Step L₁ L₂) : Join Red L₁ L₂ :=
371-
join_of_single reflexive_reflTransGen h.to_red
370+
theorem join_red_of_step (h : Red.Step L₁ L₂) : Join Red L₁ L₂ := by
371+
unfold Red
372+
exact join_of_single h.to_red
372373

373374
@[to_additive]
374375
theorem eqvGen_step_iff_join_red : EqvGen Red.Step L₁ L₂ ↔ Join Red L₁ L₂ :=

Mathlib/Logic/Pairwise.lean

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ theorem Pairwise.imp (h : s.Pairwise r) (hpq : ∀ ⦃a b : α⦄, r a b → p a
9696
protected theorem Pairwise.eq (hs : s.Pairwise r) (ha : a ∈ s) (hb : b ∈ s) (h : ¬r a b) : a = b :=
9797
of_not_not fun hab => h <| hs ha hb hab
9898

99-
theorem _root_.Reflexive.set_pairwise_iff (hr : Reflexive r) :
99+
theorem _root_.Std.Refl.set_pairwise_iff [Std.Refl r] :
100100
s.Pairwise r ↔ ∀ ⦃a⦄, a ∈ s → ∀ ⦃b⦄, b ∈ s → r a b :=
101101
forall₄_congr fun a _ _ _ => or_iff_not_imp_left.symm.trans <| or_iff_right_of_imp <| Eq.ndrec <|
102-
hr a
102+
refl a
103+
104+
@[deprecated (since := "2026-03-27")]
105+
alias _root_.Reflexive.set_pairwise_iff := Std.Refl.set_pairwise_iff
103106

104107
theorem Pairwise.on_injective (hs : s.Pairwise r) (hf : Function.Injective f) (hfs : ∀ x, f x ∈ s) :
105108
Pairwise (r on f) := fun i j hij => hs (hfs i) (hfs j) (hf.ne hij)

0 commit comments

Comments
 (0)