Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit d94f0a2

Browse files
committed
chore(data/list): a list sorted w.r.t. (<) has no duplicates (#5550)
1 parent 409ea42 commit d94f0a2

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/data/list/nodup.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ namespace list
2828
@[simp] theorem nodup_cons {a : α} {l : list α} : nodup (a::l) ↔ a ∉ l ∧ nodup l :=
2929
by simp only [nodup, pairwise_cons, forall_mem_ne]
3030

31+
protected lemma pairwise.nodup {l : list α} {r : α → α → Prop} [is_irrefl α r] (h : pairwise r l) :
32+
nodup l :=
33+
h.imp $ λ a b, ne_of_irrefl
34+
3135
lemma rel_nodup {r : α → β → Prop} (hr : relator.bi_unique r) : (forall₂ r ⇒ (↔)) nodup nodup
3236
| _ _ forall₂.nil := by simp only [nodup_nil]
3337
| _ _ (forall₂.cons hab h) :=

src/data/list/sort.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ rel_of_pairwise_cons
4949
sorted r (a :: l) ↔ (∀ b ∈ l, r a b) ∧ sorted r l :=
5050
pairwise_cons
5151

52+
protected theorem sorted.nodup {r : α → α → Prop} [is_irrefl α r] {l : list α} (h : sorted r l) :
53+
nodup l :=
54+
h.nodup
55+
5256
theorem eq_of_perm_of_sorted [is_antisymm α r]
5357
{l₁ l₂ : list α} (p : l₁ ~ l₂) (s₁ : sorted r l₁) (s₂ : sorted r l₂) : l₁ = l₂ :=
5458
begin

src/order/rel_classes.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ instance [linear_order α] : is_trichotomous α (>) := is_trichotomous.swap _
8383
instance order_dual.is_total_le [has_le α] [is_total α (≤)] : is_total (order_dual α) (≤) :=
8484
@is_total.swap α _ _
8585

86+
lemma ne_of_irrefl {r} [is_irrefl α r] : ∀ {x y : α}, r x y → x ≠ y
87+
| _ _ h rfl := irrefl _ h
88+
8689
lemma trans_trichotomous_left [is_trans α r] [is_trichotomous α r] {a b c : α} :
8790
¬r b a → r b c → r a c :=
8891
begin

0 commit comments

Comments
 (0)