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

Commit b630b8c

Browse files
committed
feat(order/antichain): Strong antichains (#11400)
This introduces a predicate `is_strong_antichain` to state that a set is a strong antichain with respect to a relation. `s` is a strong (upward) antichain wrt `r` if for all `a ≠ b` in `s` there is some `c` such that `¬ r a c` or `¬ r b c`. A strong downward antichain of the swapped relation.
1 parent 0ca7795 commit b630b8c

File tree

4 files changed

+80
-13
lines changed

4 files changed

+80
-13
lines changed

src/data/set/pairwise.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ lemma pairwise.mono (h : t ⊆ s) (hs : s.pairwise r) : t.pairwise r :=
7575

7676
lemma pairwise.mono' (H : r ≤ p) (hr : s.pairwise r) : s.pairwise p := hr.imp H
7777

78+
protected lemma pairwise.eq (hs : s.pairwise r) (ha : a ∈ s) (hb : b ∈ s) (h : ¬ r a b) : a = b :=
79+
of_not_not $ λ hab, h $ hs ha hb hab
80+
7881
lemma pairwise_top (s : set α) : s.pairwise ⊤ := pairwise_of_forall s _ (λ a b, trivial)
7982

8083
protected lemma subsingleton.pairwise (h : s.subsingleton) (r : α → α → Prop) :
@@ -276,7 +279,7 @@ pairwise_sUnion h
276279
lemma pairwise_disjoint.elim (hs : s.pairwise_disjoint f) {i j : ι} (hi : i ∈ s) (hj : j ∈ s)
277280
(h : ¬ disjoint (f i) (f j)) :
278281
i = j :=
279-
of_not_not $ λ hij, h $ hs hi hj hij
282+
hs.eq hi hj h
280283

281284
-- classical
282285
lemma pairwise_disjoint.elim' (hs : s.pairwise_disjoint f) {i j : ι} (hi : i ∈ s) (hj : j ∈ s)

src/order/antichain.lean

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ relation is `G.adj` for `G : simple_graph α`, this corresponds to independent s
1515
## Definitions
1616
1717
* `is_antichain r s`: Any two elements of `s : set α` are unrelated by `r : α → α → Prop`.
18+
* `is_strong_antichain r s`: Any two elements of `s : set α` are not related by `r : α → α → Prop`
19+
to a common element.
1820
* `is_antichain.mk r s`: Turns `s` into an antichain by keeping only the "maximal" elements.
1921
-/
2022

@@ -37,24 +39,24 @@ lemma mono_on (hs : is_antichain r₁ s) (h : s.pairwise (λ ⦃a b⦄, r₂ a b
3739
is_antichain r₂ s :=
3840
hs.imp_on $ h.imp $ λ a b h h₁ h₂, h₁ $ h h₂
3941

40-
lemma eq_of_related (hs : is_antichain r s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) (h : r a b) :
42+
protected lemma eq (hs : is_antichain r s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) (h : r a b) :
4143
a = b :=
42-
of_not_not $ λ hab, hs ha hb hab h
44+
hs.eq ha hb $ not_not_intro h
4345

44-
lemma eq_of_related' (hs : is_antichain r s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) (h : r b a) :
46+
protected lemma eq' (hs : is_antichain r s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) (h : r b a) :
4547
a = b :=
46-
(hs.eq_of_related hb ha h).symm
48+
(hs.eq hb ha h).symm
4749

4850
protected lemma is_antisymm (h : is_antichain r univ) : is_antisymm α r :=
49-
⟨λ a b ha _, h.eq_of_related trivial trivial ha⟩
51+
⟨λ a b ha _, h.eq trivial trivial ha⟩
5052

5153
protected lemma subsingleton [is_trichotomous α r] (h : is_antichain r s) : s.subsingleton :=
5254
begin
5355
rintro a ha b hb,
5456
obtain hab | hab | hab := trichotomous_of r a b,
55-
{ exact h.eq_of_related ha hb hab },
57+
{ exact h.eq ha hb hab },
5658
{ exact hab },
57-
{ exact (h.eq_of_related hb ha hab).symm }
59+
{ exact h.eq' ha hb hab }
5860
end
5961

6062
protected lemma flip (hs : is_antichain r s) : is_antichain (flip r) s :=
@@ -104,11 +106,11 @@ section preorder
104106
variables [preorder α]
105107

106108
lemma is_antichain_and_least_iff : is_antichain (≤) s ∧ is_least s a ↔ s = {a} :=
107-
⟨λ h, eq_singleton_iff_unique_mem.2 ⟨h.2.1, λ b hb, h.1.eq_of_related' hb h.2.1 (h.2.2 hb)⟩,
109+
⟨λ h, eq_singleton_iff_unique_mem.2 ⟨h.2.1, λ b hb, h.1.eq' hb h.2.1 (h.2.2 hb)⟩,
108110
by { rintro rfl, exact ⟨is_antichain_singleton _ _, is_least_singleton⟩ }⟩
109111

110112
lemma is_antichain_and_greatest_iff : is_antichain (≤) s ∧ is_greatest s a ↔ s = {a} :=
111-
⟨λ h, eq_singleton_iff_unique_mem.2 ⟨h.2.1, λ b hb, h.1.eq_of_related hb h.2.1 (h.2.2 hb)⟩,
113+
⟨λ h, eq_singleton_iff_unique_mem.2 ⟨h.2.1, λ b hb, h.1.eq hb h.2.1 (h.2.2 hb)⟩,
112114
by { rintro rfl, exact ⟨is_antichain_singleton _ _, is_greatest_singleton⟩ }⟩
113115

114116
lemma is_antichain.least_iff (hs : is_antichain (≤) s) : is_least s a ↔ s = {a} :=
@@ -130,3 +132,65 @@ lemma is_antichain.top_mem_iff [order_top α] (hs : is_antichain (≤) s) : ⊤
130132
is_greatest_top_iff.symm.trans hs.greatest_iff
131133

132134
end preorder
135+
136+
/-! ### Strong antichains -/
137+
138+
/-- An strong (upward) antichain is a set such that no two distinct elements are related to a common
139+
element. -/
140+
def is_strong_antichain (r : α → α → Prop) (s : set α) : Prop :=
141+
s.pairwise $ λ a b, ∀ c, ¬ r a c ∨ ¬ r b c
142+
143+
namespace is_strong_antichain
144+
145+
protected lemma subset (hs : is_strong_antichain r s) (h : t ⊆ s) : is_strong_antichain r t :=
146+
hs.mono h
147+
148+
lemma mono (hs : is_strong_antichain r₁ s) (h : r₂ ≤ r₁) : is_strong_antichain r₂ s :=
149+
hs.mono' $ λ a b hab c, (hab c).imp (compl_le_compl h _ _) (compl_le_compl h _ _)
150+
151+
lemma eq (hs : is_strong_antichain r s) {a b c : α} (ha : a ∈ s) (hb : b ∈ s) (hac : r a c)
152+
(hbc : r b c) :
153+
a = b :=
154+
hs.eq ha hb $ λ h, false.elim $ (h c).elim (not_not_intro hac) (not_not_intro hbc)
155+
156+
protected lemma is_antichain [is_refl α r] (h : is_strong_antichain r s) : is_antichain r s :=
157+
h.imp $ λ a b hab, (hab b).resolve_right (not_not_intro $ refl _)
158+
159+
protected lemma subsingleton [is_directed α r] (h : is_strong_antichain r s) : s.subsingleton :=
160+
λ a ha b hb, let ⟨c, hac, hbc⟩ := directed_of r a b in h.eq ha hb hac hbc
161+
162+
protected lemma flip [is_symm α r] (hs : is_strong_antichain r s) :
163+
is_strong_antichain (flip r) s :=
164+
λ a ha b hb h c, (hs ha hb h c).imp (mt $ symm_of r) (mt $ symm_of r)
165+
166+
lemma swap [is_symm α r] (hs : is_strong_antichain r s) : is_strong_antichain (swap r) s := hs.flip
167+
168+
lemma image (hs : is_strong_antichain r s) {f : α → β} (hf : surjective f)
169+
(h : ∀ a b, r' (f a) (f b) → r a b) :
170+
is_strong_antichain r' (f '' s) :=
171+
begin
172+
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ hab c,
173+
obtain ⟨c, rfl⟩ := hf c,
174+
exact (hs ha hb (ne_of_apply_ne _ hab) _).imp (mt $ h _ _) (mt $ h _ _),
175+
end
176+
177+
lemma preimage (hs : is_strong_antichain r s) {f : β → α} (hf : injective f)
178+
(h : ∀ a b, r' a b → r (f a) (f b)) :
179+
is_strong_antichain r' (f ⁻¹' s) :=
180+
λ a ha b hb hab c, (hs ha hb (hf.ne hab) _).imp (mt $ h _ _) (mt $ h _ _)
181+
182+
lemma _root_.is_strong_antichain_insert :
183+
is_strong_antichain r (insert a s) ↔ is_strong_antichain r s ∧
184+
∀ ⦃b⦄, b ∈ s → a ≠ b → ∀ c, ¬ r a c ∨ ¬ r b c :=
185+
set.pairwise_insert_of_symmetric $ λ a b h c, (h c).symm
186+
187+
protected lemma insert (hs : is_strong_antichain r s)
188+
(h : ∀ ⦃b⦄, b ∈ s → a ≠ b → ∀ c, ¬ r a c ∨ ¬ r b c) :
189+
is_strong_antichain r (insert a s) :=
190+
is_strong_antichain_insert.2 ⟨hs, h⟩
191+
192+
end is_strong_antichain
193+
194+
lemma set.subsingleton.is_strong_antichain (hs : s.subsingleton) (r : α → α → Prop) :
195+
is_strong_antichain r s :=
196+
hs.pairwise _

src/order/minimal.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ lemma inter_maximals_subset : s ∩ maximals r t ⊆ maximals r (s ∩ t) :=
8484
lemma inter_minimals_subset : s ∩ minimals r t ⊆ minimals r (s ∩ t) := inter_maximals_subset
8585

8686
lemma _root_.is_antichain.maximals_eq (h : is_antichain r s) : maximals r s = s :=
87-
(maximals_subset _ _).antisymm $ λ a ha, ⟨ha, λ b, h.eq_of_related ha⟩
87+
(maximals_subset _ _).antisymm $ λ a ha, ⟨ha, λ b, h.eq ha⟩
8888

8989
lemma _root_.is_antichain.minimals_eq (h : is_antichain r s) : minimals r s = s :=
90-
(minimals_subset _ _).antisymm $ λ a ha, ⟨ha, λ b, h.eq_of_related' ha⟩
90+
(minimals_subset _ _).antisymm $ λ a ha, ⟨ha, λ b, h.eq' ha⟩
9191

9292
@[simp] lemma maximals_idem : maximals r (maximals r s) = maximals r s :=
9393
(maximals_antichain _ _).maximals_eq

src/order/well_founded_set.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ begin
214214
obtain ⟨m, n, hmn, h⟩ := hp (λ n, hi.nat_embedding _ n) (range_subset_iff.2 $
215215
λ n, (hi.nat_embedding _ n).2),
216216
exact hmn.ne ((hi.nat_embedding _).injective $ subtype.val_injective $
217-
ha.eq_of_related (hi.nat_embedding _ m).2 (hi.nat_embedding _ n).2 h),
217+
ha.eq (hi.nat_embedding _ m).2 (hi.nat_embedding _ n).2 h),
218218
end
219219

220220
lemma finite.partially_well_ordered_on {s : set α} {r : α → α → Prop} [is_refl α r]

0 commit comments

Comments
 (0)