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

Commit 34c3668

Browse files
committed
chore(data/set/intervals/ord_connected): make it more useful as a typeclass (#4879)
* Add `protected lemma set.Icc_subset` that looks for `ord_connected s` instance. * Add `instance` versions to more lemmas. * Add `ord_connected_pi`.
1 parent 9851a88 commit 34c3668

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

src/data/set/intervals/ord_connected.lean

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,18 @@ begin
4747
simp [*, insert_subset]
4848
end
4949

50+
protected lemma Icc_subset (s : set α) [hs : ord_connected s] {x y} (hx : x ∈ s) (hy : y ∈ s) :
51+
Icc x y ⊆ s :=
52+
hs hx hy
53+
5054
lemma ord_connected.inter {s t : set α} (hs : ord_connected s) (ht : ord_connected t) :
5155
ord_connected (s ∩ t) :=
5256
λ x hx y hy, subset_inter (hs hx.1 hy.1) (ht hx.2 hy.2)
5357

58+
instance ord_connected.inter' {s t : set α} [ord_connected s] [ord_connected t] :
59+
ord_connected (s ∩ t) :=
60+
ord_connected.inter ‹_› ‹_›
61+
5462
lemma ord_connected.dual {s : set α} (hs : ord_connected s) : @ord_connected (order_dual α) _ s :=
5563
λ x hx y hy z hz, hs hy hx ⟨hz.2, hz.1
5664

@@ -65,38 +73,54 @@ lemma ord_connected_Inter {ι : Sort*} {s : ι → set α} (hs : ∀ i, ord_conn
6573
ord_connected (⋂ i, s i) :=
6674
ord_connected_sInter $ forall_range_iff.2 hs
6775

76+
instance ord_connected_Inter' {ι : Sort*} {s : ι → set α} [∀ i, ord_connected (s i)] :
77+
ord_connected (⋂ i, s i) :=
78+
ord_connected_Inter ‹_›
79+
6880
lemma ord_connected_bInter {ι : Sort*} {p : ι → Prop} {s : Π (i : ι) (hi : p i), set α}
6981
(hs : ∀ i hi, ord_connected (s i hi)) :
7082
ord_connected (⋂ i hi, s i hi) :=
7183
ord_connected_Inter $ λ i, ord_connected_Inter $ hs i
7284

73-
lemma ord_connected_Ici {a : α} : ord_connected (Ici a) := λ x hx y hy z hz, le_trans hx hz.1
74-
lemma ord_connected_Iic {a : α} : ord_connected (Iic a) := λ x hx y hy z hz, le_trans hz.2 hy
75-
lemma ord_connected_Ioi {a : α} : ord_connected (Ioi a) := λ x hx y hy z hz, lt_of_lt_of_le hx hz.1
76-
lemma ord_connected_Iio {a : α} : ord_connected (Iio a) := λ x hx y hy z hz, lt_of_le_of_lt hz.2 hy
85+
lemma ord_connected_pi {ι : Type*} {α : ι → Type*} [Π i, preorder (α i)] {s : set ι}
86+
{t : Π i, set (α i)} (h : ∀ i ∈ s, ord_connected (t i)) : ord_connected (s.pi t) :=
87+
λ x hx y hy z hz i hi, h i hi (hx i hi) (hy i hi) ⟨hz.1 i, hz.2 i⟩
88+
89+
instance ord_connected_pi' {ι : Type*} {α : ι → Type*} [Π i, preorder (α i)] {s : set ι}
90+
{t : Π i, set (α i)} [h : ∀ i, ord_connected (t i)] : ord_connected (s.pi t) :=
91+
ord_connected_pi $ λ i hi, h i
7792

78-
lemma ord_connected_Icc {a b : α} : ord_connected (Icc a b) :=
93+
@[instance] lemma ord_connected_Ici {a : α} : ord_connected (Ici a) :=
94+
λ x hx y hy z hz, le_trans hx hz.1
95+
96+
@[instance] lemma ord_connected_Iic {a : α} : ord_connected (Iic a) :=
97+
λ x hx y hy z hz, le_trans hz.2 hy
98+
99+
@[instance] lemma ord_connected_Ioi {a : α} : ord_connected (Ioi a) :=
100+
λ x hx y hy z hz, lt_of_lt_of_le hx hz.1
101+
102+
@[instance] lemma ord_connected_Iio {a : α} : ord_connected (Iio a) :=
103+
λ x hx y hy z hz, lt_of_le_of_lt hz.2 hy
104+
105+
@[instance] lemma ord_connected_Icc {a b : α} : ord_connected (Icc a b) :=
79106
ord_connected_Ici.inter ord_connected_Iic
80107

81-
lemma ord_connected_Ico {a b : α} : ord_connected (Ico a b) :=
108+
@[instance] lemma ord_connected_Ico {a b : α} : ord_connected (Ico a b) :=
82109
ord_connected_Ici.inter ord_connected_Iio
83110

84-
lemma ord_connected_Ioc {a b : α} : ord_connected (Ioc a b) :=
111+
@[instance] lemma ord_connected_Ioc {a b : α} : ord_connected (Ioc a b) :=
85112
ord_connected_Ioi.inter ord_connected_Iic
86113

87-
lemma ord_connected_Ioo {a b : α} : ord_connected (Ioo a b) :=
114+
@[instance] lemma ord_connected_Ioo {a b : α} : ord_connected (Ioo a b) :=
88115
ord_connected_Ioi.inter ord_connected_Iio
89116

90-
attribute [instance] ord_connected_Ici ord_connected_Iic ord_connected_Ioi ord_connected_Iio
91-
ord_connected_Icc ord_connected_Ico ord_connected_Ioc ord_connected_Ioo
92-
93-
lemma ord_connected_singleton {α : Type*} [partial_order α] {a : α} :
117+
@[instance] lemma ord_connected_singleton {α : Type*} [partial_order α] {a : α} :
94118
ord_connected ({a} : set α) :=
95119
by { rw ← Icc_self, exact ord_connected_Icc }
96120

97-
lemma ord_connected_empty : ord_connected (∅ : set α) := λ x, false.elim
121+
@[instance] lemma ord_connected_empty : ord_connected (∅ : set α) := λ x, false.elim
98122

99-
lemma ord_connected_univ : ord_connected (univ : set α) := λ _ _ _ _, subset_univ _
123+
@[instance] lemma ord_connected_univ : ord_connected (univ : set α) := λ _ _ _ _, subset_univ _
100124

101125
/-- In a dense order `α`, the subtype from an `ord_connected` set is also densely ordered. -/
102126
instance [densely_ordered α] {s : set α} [hs : ord_connected s] :
@@ -111,7 +135,7 @@ instance [densely_ordered α] {s : set α} [hs : ord_connected s] :
111135

112136
variables {β : Type*} [linear_order β]
113137

114-
lemma ord_connected_interval {a b : β} : ord_connected (interval a b) :=
138+
@[instance] lemma ord_connected_interval {a b : β} : ord_connected (interval a b) :=
115139
ord_connected_Icc
116140

117141
lemma ord_connected.interval_subset {s : set β} (hs : ord_connected s)

0 commit comments

Comments
 (0)