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

Commit a43fe8b

Browse files
committed
chore(data/set/bool_indicator): split to a new file (#17841)
`data/set/basic` is long, and this definition is almost never used. Let's put it in its own file.
1 parent 7ab3af8 commit a43fe8b

File tree

4 files changed

+56
-43
lines changed

4 files changed

+56
-43
lines changed

src/data/set/basic.lean

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,46 +2819,3 @@ instance decidable_set_of (p : α → Prop) [decidable (p a)] : decidable (a ∈
28192819
by assumption
28202820

28212821
end set
2822-
2823-
/-! ### Indicator function valued in bool -/
2824-
2825-
open bool
2826-
2827-
namespace set
2828-
variables {α : Type*} (s : set α)
2829-
2830-
/-- `bool_indicator` maps `x` to `tt` if `x ∈ s`, else to `ff` -/
2831-
noncomputable def bool_indicator (x : α) :=
2832-
@ite _ (x ∈ s) (classical.prop_decidable _) tt ff
2833-
2834-
lemma mem_iff_bool_indicator (x : α) : x ∈ s ↔ s.bool_indicator x = tt :=
2835-
by { unfold bool_indicator, split_ifs ; tauto }
2836-
2837-
lemma not_mem_iff_bool_indicator (x : α) : x ∉ s ↔ s.bool_indicator x = ff :=
2838-
by { unfold bool_indicator, split_ifs ; tauto }
2839-
2840-
lemma preimage_bool_indicator_tt : s.bool_indicator ⁻¹' {tt} = s :=
2841-
ext (λ x, (s.mem_iff_bool_indicator x).symm)
2842-
2843-
lemma preimage_bool_indicator_ff : s.bool_indicator ⁻¹' {ff} = sᶜ :=
2844-
ext (λ x, (s.not_mem_iff_bool_indicator x).symm)
2845-
2846-
open_locale classical
2847-
2848-
lemma preimage_bool_indicator_eq_union (t : set bool) :
2849-
s.bool_indicator ⁻¹' t = (if tt ∈ t then s else ∅) ∪ (if ff ∈ t then sᶜ else ∅) :=
2850-
begin
2851-
ext x,
2852-
dsimp [bool_indicator],
2853-
split_ifs ; tauto
2854-
end
2855-
2856-
lemma preimage_bool_indicator (t : set bool) :
2857-
s.bool_indicator ⁻¹' t = univ ∨ s.bool_indicator ⁻¹' t = s ∨
2858-
s.bool_indicator ⁻¹' t = sᶜ ∨ s.bool_indicator ⁻¹' t = ∅ :=
2859-
begin
2860-
simp only [preimage_bool_indicator_eq_union],
2861-
split_ifs ; simp [s.union_compl_self]
2862-
end
2863-
2864-
end set

src/data/set/bool_indicator.lean

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/-
2+
Copyright (c) 2022 Dagur Tómas Ásgeirsson. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Dagur Tómas Ásgeirsson, Leonardo de Moura
5+
-/
6+
7+
import data.set.basic
8+
9+
/-!
10+
# Indicator function valued in bool
11+
12+
See also `set.indicator` and `set.piecewise`.
13+
-/
14+
15+
open bool
16+
17+
namespace set
18+
variables {α : Type*} (s : set α)
19+
20+
/-- `bool_indicator` maps `x` to `tt` if `x ∈ s`, else to `ff` -/
21+
noncomputable def bool_indicator (x : α) :=
22+
@ite _ (x ∈ s) (classical.prop_decidable _) tt ff
23+
24+
lemma mem_iff_bool_indicator (x : α) : x ∈ s ↔ s.bool_indicator x = tt :=
25+
by { unfold bool_indicator, split_ifs ; tauto }
26+
27+
lemma not_mem_iff_bool_indicator (x : α) : x ∉ s ↔ s.bool_indicator x = ff :=
28+
by { unfold bool_indicator, split_ifs ; tauto }
29+
30+
lemma preimage_bool_indicator_tt : s.bool_indicator ⁻¹' {tt} = s :=
31+
ext (λ x, (s.mem_iff_bool_indicator x).symm)
32+
33+
lemma preimage_bool_indicator_ff : s.bool_indicator ⁻¹' {ff} = sᶜ :=
34+
ext (λ x, (s.not_mem_iff_bool_indicator x).symm)
35+
36+
open_locale classical
37+
38+
lemma preimage_bool_indicator_eq_union (t : set bool) :
39+
s.bool_indicator ⁻¹' t = (if tt ∈ t then s else ∅) ∪ (if ff ∈ t then sᶜ else ∅) :=
40+
begin
41+
ext x,
42+
dsimp [bool_indicator],
43+
split_ifs ; tauto
44+
end
45+
46+
lemma preimage_bool_indicator (t : set bool) :
47+
s.bool_indicator ⁻¹' t = univ ∨ s.bool_indicator ⁻¹' t = s ∨
48+
s.bool_indicator ⁻¹' t = sᶜ ∨ s.bool_indicator ⁻¹' t = ∅ :=
49+
begin
50+
simp only [preimage_bool_indicator_eq_union],
51+
split_ifs ; simp [s.union_compl_self]
52+
end
53+
54+
end set

src/topology/connected.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Copyright (c) 2017 Johannes Hölzl. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov
55
-/
6+
import data.set.bool_indicator
67
import order.succ_pred.relation
78
import topology.subset_properties
89
import tactic.congrm

src/topology/subset_properties.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import order.filter.pi
77
import topology.bases
88
import data.finset.order
99
import data.set.accumulate
10+
import data.set.bool_indicator
1011
import topology.bornology.basic
1112
import order.minimal
1213

0 commit comments

Comments
 (0)