Skip to content

Commit

Permalink
feat(data/list/pairwise): pairwise_of_forall_mem_list (#12968)
Browse files Browse the repository at this point in the history
A relation holds pairwise on a list when it does on any two of its elements.
  • Loading branch information
vihdzp committed Mar 28, 2022
1 parent 73a9c27 commit 4b05a42
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/data/list/pairwise.lean
Expand Up @@ -268,14 +268,19 @@ begin
exact h x (mem_cons_of_mem _ hx) y (mem_cons_of_mem _ hy) } } }
end

lemma pairwise_of_reflexive_of_forall_ne {l : list α} {r : α → α → Prop}
(hr : reflexive r) (h : ∀ (a ∈ l) (b ∈ l), a ≠ b → r a b) : l.pairwise r :=
lemma pairwise_of_forall_mem_list {l : list α} {r : α → α → Prop} (h : ∀ (a ∈ l) (b ∈ l), r a b) :
l.pairwise r :=
begin
classical,
refine pairwise_of_reflexive_on_dupl_of_forall_ne _ h,
exact λ _ _, hr _
refine pairwise_of_reflexive_on_dupl_of_forall_ne (λ a ha', _) (λ a ha b hb _, h a ha b hb),
have ha := list.one_le_count_iff_mem.1 ha'.le,
exact h a ha a ha
end

lemma pairwise_of_reflexive_of_forall_ne {l : list α} {r : α → α → Prop}
(hr : reflexive r) (h : ∀ (a ∈ l) (b ∈ l), a ≠ b → r a b) : l.pairwise r :=
by { classical, exact pairwise_of_reflexive_on_dupl_of_forall_ne (λ _ _, hr _) h }

theorem pairwise_iff_nth_le {R} : ∀ {l : list α},
pairwise R l ↔ ∀ i j (h₁ : j < length l) (h₂ : i < j),
R (nth_le l i (lt_trans h₂ h₁)) (nth_le l j h₁)
Expand Down

0 comments on commit 4b05a42

Please sign in to comment.