Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace the compare_self simp lemma with a less generic one #7222

Merged
merged 2 commits into from
Feb 25, 2025
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/Std/Classes/Ord.lean
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ class ReflCmp {α : Type u} (cmp : α → α → Ordering) : Prop where
/-- Comparison is reflexive. -/
compare_self {a : α} : cmp a a = .eq

export ReflCmp (compare_self)

/-- A typeclasses for ordered types for which `compare a a = .eq` for all `a`. -/
abbrev ReflOrd (α : Type u) [Ord α] := ReflCmp (compare : α → α → Ordering)

attribute [simp] compare_self
@[simp]
theorem ReflOrd.compare_self {α : Type u} [Ord α] [ReflOrd α] {a : α} : compare a a = .eq :=
ReflCmp.compare_self

export ReflOrd (compare_self)

end Refl

Expand Down Expand Up @@ -266,7 +268,7 @@ variable {α : Type u} {cmp : α → α → Ordering} [LawfulEqCmp cmp]

@[simp]
theorem compare_eq_iff_eq {a b : α} : cmp a b = .eq ↔ a = b :=
⟨LawfulEqCmp.eq_of_compare, by rintro rfl; simp
⟨LawfulEqCmp.eq_of_compare, by rintro rfl; exact ReflCmp.compare_self

@[simp]
theorem compare_beq_iff_eq {a b : α} : cmp a b == .eq ↔ a = b :=
Expand All @@ -293,7 +295,7 @@ theorem beq_eq [Ord α] {a b : α} : (a == b) = (compare a b == .eq) :=
theorem equivBEq_of_transOrd [Ord α] [TransOrd α] : EquivBEq α where
symm {a b} h := by simp_all [OrientedCmp.eq_comm]
trans h₁ h₂ := by simp_all only [beq_eq, beq_iff_eq]; exact TransCmp.eq_trans h₁ h₂
refl := by simp
refl := by simp only [beq_eq, beq_iff_eq]; exact compare_self

theorem lawfulBEq_of_lawfulEqOrd [Ord α] [LawfulEqOrd α] : LawfulBEq α where
eq_of_beq hbeq := by simp_all
Expand Down
2 changes: 1 addition & 1 deletion src/Std/Data/DTreeMap/Internal/Cell.lean
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def ofEq [Ord α] {k : α → Ordering} (k' : α) (v' : β k') (hcmp : ∀ [Orie

/-- Create a cell with a matching key. Internal implementation detail of the tree map -/
def of [Ord α] (k : α) (v : β k) : Cell α β (compare k) :=
.ofEq k v (by intro; simp)
.ofEq k v compare_self

@[simp]
theorem ofEq_inner [Ord α] {k : α → Ordering} {k' : α} {v' : β k'} {h} :
Expand Down
Loading