@@ -227,6 +227,54 @@ from λ R l, ⟨λ p, reverse_reverse l ▸ this p, this⟩,
227
227
pairwise_cons, forall_prop_of_false (not_mem_nil _), forall_true_iff,
228
228
pairwise.nil, mem_reverse, mem_singleton, forall_eq, true_and] using h]
229
229
230
+ lemma pairwise.set_pairwise_on {l : list α} (h : pairwise R l) (hr : symmetric R) :
231
+ set.pairwise_on {x | x ∈ l} R :=
232
+ begin
233
+ induction h with hd tl imp h IH,
234
+ { simp },
235
+ { intros x hx y hy hxy,
236
+ simp only [mem_cons_iff, set.mem_set_of_eq] at hx hy,
237
+ rcases hx with rfl|hx;
238
+ rcases hy with rfl|hy,
239
+ { contradiction },
240
+ { exact imp y hy },
241
+ { exact hr (imp x hx) },
242
+ { exact IH x hx y hy hxy } }
243
+ end
244
+
245
+ lemma pairwise_of_reflexive_on_dupl_of_forall_ne [decidable_eq α] {l : list α} {r : α → α → Prop }
246
+ (hr : ∀ a, 1 < count a l → r a a)
247
+ (h : ∀ (a ∈ l) (b ∈ l), a ≠ b → r a b) : l.pairwise r :=
248
+ begin
249
+ induction l with hd tl IH,
250
+ { simp },
251
+ { rw list.pairwise_cons,
252
+ split,
253
+ { intros x hx,
254
+ by_cases H : hd = x,
255
+ { rw H,
256
+ refine hr _ _,
257
+ simpa [count_cons, H, nat.succ_lt_succ_iff, count_pos] using hx },
258
+ { exact h hd (mem_cons_self _ _) x (mem_cons_of_mem _ hx) H } },
259
+ { refine IH _ _,
260
+ { intros x hx,
261
+ refine hr _ _,
262
+ rw count_cons,
263
+ split_ifs,
264
+ { exact hx.trans (nat.lt_succ_self _) },
265
+ { exact hx } },
266
+ { intros x hx y hy,
267
+ exact h x (mem_cons_of_mem _ hx) y (mem_cons_of_mem _ hy) } } }
268
+ end
269
+
270
+ lemma pairwise_of_reflexive_of_forall_ne {l : list α} {r : α → α → Prop }
271
+ (hr : reflexive r) (h : ∀ (a ∈ l) (b ∈ l), a ≠ b → r a b) : l.pairwise r :=
272
+ begin
273
+ classical,
274
+ refine pairwise_of_reflexive_on_dupl_of_forall_ne _ h,
275
+ exact λ _ _, hr _
276
+ end
277
+
230
278
theorem pairwise_iff_nth_le {R} : ∀ {l : list α},
231
279
pairwise R l ↔ ∀ i j (h₁ : j < length l) (h₂ : i < j),
232
280
R (nth_le l i (lt_trans h₂ h₁)) (nth_le l j h₁)
0 commit comments