Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat(combinatorics/simple_graph/srg): is_SRG_with for complete graphs, edgeless graphs, and complements #5698

Closed
wants to merge 137 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
38df43b
added stuff
agusakov Jan 11, 2021
329778b
complement definition added
agusakov Jan 11, 2021
d2dea9f
added docstring
agusakov Jan 11, 2021
28ac3c6
satisfying linter
agusakov Jan 11, 2021
3f966e8
more satisfying linter
agusakov Jan 11, 2021
3f88e00
Update src/combinatorics/simple_graph/srg.lean
agusakov Jan 11, 2021
9d54c75
moving stuff around
agusakov Jan 11, 2021
6c08973
added complement involutive lemma
agusakov Jan 11, 2021
c2120f2
renamed to match mathlib naming conventions?
agusakov Jan 11, 2021
b20a4a6
added suggestions
agusakov Jan 11, 2021
7bfd16c
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Jan 11, 2021
a57db2d
updated docstring
agusakov Jan 11, 2021
04b166e
Update src/combinatorics/simple_graph/basic.lean
agusakov Jan 12, 2021
e2c867b
Update src/combinatorics/simple_graph/basic.lean
agusakov Jan 12, 2021
8c425ec
added kyle's lemmas
agusakov Jan 12, 2021
d7ebb71
Merge branch 'graph_compl' of https://github.com/leanprover-community…
agusakov Jan 12, 2021
e8af6cc
updating
agusakov Jan 12, 2021
b0b002e
added has_compl instance
agusakov Jan 12, 2021
d6c7c44
added def and lemmas
agusakov Jan 12, 2021
05aec79
added degree lemma
agusakov Jan 12, 2021
61341e5
added rw lemma
agusakov Jan 12, 2021
a97948b
Update src/combinatorics/simple_graph/basic.lean
agusakov Jan 12, 2021
a4616ac
Update src/combinatorics/simple_graph/basic.lean
agusakov Jan 12, 2021
392f41c
Update src/combinatorics/simple_graph/basic.lean
agusakov Jan 12, 2021
dc355e0
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Jan 12, 2021
75d09b2
Merge branch 'graph_compl' of https://github.com/leanprover-community…
agusakov Jan 12, 2021
864dbcc
fixed
agusakov Jan 12, 2021
4a8f932
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Jan 13, 2021
906e4a9
added lemma
agusakov Jan 13, 2021
3fefd2c
merged in graph_compl
agusakov Jan 13, 2021
4556767
Merge branch 'to_finset_subset' of https://github.com/leanprover-comm…
agusakov Jan 13, 2021
b2f512b
moved stuff around
agusakov Jan 13, 2021
45bbb22
Merge branch 'graph_common_neighbors' of https://github.com/leanprove…
agusakov Jan 13, 2021
1a03326
added more info
agusakov Jan 13, 2021
bf5a291
integrated changes
agusakov Jan 13, 2021
88d4d14
Update src/data/set/finite.lean
agusakov Jan 13, 2021
6f1fb32
fdsjkfndjks
agusakov Jan 13, 2021
5f07caa
Merge branch 'to_finset_subset' of https://github.com/leanprover-comm…
agusakov Jan 13, 2021
1a38f5b
Merge branch 'graph_common_neighbors' of https://github.com/leanprove…
agusakov Jan 13, 2021
88a06b3
Merge branch 'to_finset_subset' of https://github.com/leanprover-comm…
agusakov Jan 13, 2021
f4f2946
adsadsa
agusakov Jan 13, 2021
413c30c
removed unnecessary parens
agusakov Jan 13, 2021
1d9eb3c
Merge branch 'graph_common_neighbors' of https://github.com/leanprove…
agusakov Jan 13, 2021
9539b11
Update src/combinatorics/simple_graph/basic.lean
agusakov Jan 13, 2021
b43275d
Merge branch 'graph_common_neighbors' of https://github.com/leanprove…
agusakov Jan 13, 2021
c46a9a0
fixed merge conflict
agusakov Jan 17, 2021
88b0bde
djakdns
agusakov Jan 17, 2021
d6ce4e9
caught up to mathlib
agusakov Jan 17, 2021
496a953
Merge branch 'common_neighbor_card' of https://github.com/leanprover-…
agusakov Jan 17, 2021
e07f2b6
moved stuff
agusakov Jan 17, 2021
afa89c2
fixed proof
agusakov Jan 17, 2021
d3c2996
made suggested changes
agusakov Jan 17, 2021
6a88ff7
fixed sorry, oops
agusakov Jan 18, 2021
dc478a3
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Jan 18, 2021
7a3b352
added docstring
agusakov Jan 18, 2021
8a8071a
Merge branch 'common_neighbor_card' of https://github.com/leanprover-…
agusakov Jan 18, 2021
7a59d3c
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Jan 18, 2021
8263f73
finsets will be the death of me
agusakov Jan 18, 2021
cc72be6
added lemma
agusakov Jan 25, 2021
62b1093
changed to simp only
agusakov Jan 25, 2021
8befd79
merge conflicts fixed
agusakov Jan 25, 2021
3c23738
removed unnecessary decl
agusakov Jan 25, 2021
42f4a08
Update src/data/fintype/basic.lean
agusakov Jan 25, 2021
ab6e768
moved lemma
agusakov Jan 25, 2021
570193a
renamed
agusakov Jan 25, 2021
a0eb685
removed from fintype
agusakov Jan 25, 2021
b43209c
removed unnecessary newline
agusakov Jan 25, 2021
59e114e
added space
agusakov Jan 25, 2021
fa1e3ac
put proof on new line to match style
agusakov Jan 25, 2021
7caadbb
Merge branch 'compl_to_finset' of https://github.com/leanprover-commu…
agusakov Jan 25, 2021
6dd6274
fixed proof
agusakov Jan 25, 2021
3dfb260
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Feb 1, 2021
3c9a850
fixed thing
agusakov Feb 1, 2021
de198b8
placeholder ig
agusakov Feb 2, 2021
f305908
dsnjakdns
agusakov Feb 2, 2021
f9b75c0
lean is being really slow
agusakov Feb 2, 2021
f215a20
fixed
agusakov Feb 10, 2021
7f91b5e
fndjskfnd
agusakov Feb 10, 2021
b76aeaf
fdjskf
agusakov Feb 10, 2021
5673f38
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Feb 10, 2021
fd982b0
fdsnjkfndskfdnsfjkdnsjfkdnsfjkdn
agusakov Feb 11, 2021
7ea3706
fdsjnkfds
agusakov Feb 11, 2021
f8134b3
ffjdsk
agusakov Feb 11, 2021
7b2a8da
deleted unnecessary thing
agusakov Feb 11, 2021
5f9a289
fdnjskfd
agusakov Mar 24, 2021
f28ed41
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Mar 24, 2021
8360dd9
djnfkdsn
agusakov Mar 24, 2021
c3874f8
completed adj_common for complete graphs
agusakov Apr 5, 2021
421eadd
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Apr 5, 2021
c65ef26
added proof that complete graph is SRG and definition of SRG
agusakov Apr 5, 2021
f5ee9a7
satisfying linter
agusakov Apr 5, 2021
ed39bd8
dnjakdsna
agusakov Apr 5, 2021
790a4d3
Update src/combinatorics/simple_graph/strongly_regular.lean
agusakov Apr 5, 2021
a50a847
added comment
agusakov Apr 5, 2021
3bb0591
Update src/combinatorics/simple_graph/strongly_regular.lean
agusakov Apr 5, 2021
c7ae403
Update src/combinatorics/simple_graph/strongly_regular.lean
agusakov Apr 5, 2021
18c5d75
Update src/combinatorics/simple_graph/strongly_regular.lean
agusakov Apr 5, 2021
391e68a
Update src/combinatorics/simple_graph/strongly_regular.lean
agusakov Apr 5, 2021
e9cc894
feat(data/fintype/basic): to_finset lattice lemmas
pechersky Apr 7, 2021
e0c9ae0
more finite lemmas
pechersky Apr 8, 2021
941de9a
fix linter
pechersky Apr 8, 2021
0567988
Apply suggestions from code review
pechersky Apr 8, 2021
afefcee
Update src/combinatorics/simple_graph/strongly_regular.lean
agusakov Apr 8, 2021
2a28cb6
moved comment about definition of common_neighbors
agusakov Apr 8, 2021
97064b1
proved complement of empty is complete
agusakov Apr 8, 2021
a3a224c
Merge branch 'complete_srg' of https://github.com/leanprover-communit…
agusakov Apr 8, 2021
40f3603
empty strongly regular
agusakov Apr 8, 2021
eaf4c25
added docstring
agusakov Apr 8, 2021
9b73c58
fdsjfbdhsj
agusakov Apr 8, 2021
9944ff8
Merge branch 'pechersky/to-finset-mono' of https://github.com/leanpro…
agusakov Apr 8, 2021
68763fe
Merge branch 'master' of https://github.com/leanprover-community/math…
agusakov Apr 8, 2021
bf693b6
complement of regular graph is regular
agusakov Apr 8, 2021
dd4bd25
little bit of golfing
agusakov Apr 8, 2021
1cf6531
fdsjfkdn
agusakov Apr 9, 2021
1410c12
i realized i need integers in order to make the complement arguments …
agusakov May 19, 2021
045fa34
switched out fintype for finset, proved nadj case for complement, swa…
agusakov May 28, 2021
80ac82d
proved the complement
agusakov May 29, 2021
8d2ddb5
Merge remote-tracking branch 'origin/master' into srg1
YaelDillies Dec 9, 2021
0c8d658
Merge branch 'master' of https://github.com/leanprover-community/math…
kmill Dec 26, 2021
e4a8799
got working again
kmill Dec 26, 2021
3ee0945
golfing
arthurpaulino Dec 26, 2021
ecbde3e
formatting; moving a lemma
arthurpaulino Dec 26, 2021
8bd41d8
fixing lint
arthurpaulino Dec 27, 2021
8b63225
expliciting structure name
arthurpaulino Dec 27, 2021
c63a61b
a little cleanup and naming
kmill Dec 27, 2021
0931de4
Spliting big proof; formatting; better docs (#11078)
arthurpaulino Dec 27, 2021
0e62d49
Apply suggestions from code review
arthurpaulino Dec 30, 2021
dd0d24e
fixes after changes
arthurpaulino Dec 30, 2021
52d0c53
more suggestions
arthurpaulino Dec 30, 2021
d38958a
fix
arthurpaulino Dec 30, 2021
07346a3
disambiguation
arthurpaulino Dec 30, 2021
3756caa
fix
arthurpaulino Dec 30, 2021
73aed15
more dot notation
kmill Dec 31, 2021
68e2fb5
rename lemma
kmill Dec 31, 2021
9a7f8d2
changed everything to \ell and \mu
kmill Dec 31, 2021
805e18c
removed set.card_to_finset_univ
kmill Dec 31, 2021
2dba4ef
bhavik suggestion
kmill Dec 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 42 additions & 11 deletions src/combinatorics/simple_graph/basic.lean
Expand Up @@ -145,6 +145,9 @@ protected lemma adj.ne {G : simple_graph V} {a b : V} (h : G.adj a b) : a ≠ b

protected lemma adj.ne' {G : simple_graph V} {a b : V} (h : G.adj a b) : b ≠ a := h.ne.symm

lemma ne_of_adj_of_not_adj {v w x : V} (h : G.adj v x) (hn : ¬ G.adj w x) : v ≠ w :=
λ h', hn (h' ▸ h)

section order

/-- The relation that one `simple_graph` is a subgraph of another.
Expand Down Expand Up @@ -278,7 +281,7 @@ def edge_set : set (sym2 V) := sym2.from_rel G.symm
@[simp] lemma mem_edge_set : ⟦(v, w)⟧ ∈ G.edge_set ↔ G.adj v w := iff.rfl

/--
Two vertices are adjacent iff there is an edge between them. The
Two vertices are adjacent iff there is an edge between them. The
condition `v ≠ w` ensures they are different endpoints of the edge,
which is necessary since when `v = w` the existential
`∃ (e ∈ G.edge_set), v ∈ e ∧ w ∈ e` is satisfied by every edge
Expand Down Expand Up @@ -450,6 +453,10 @@ instance decidable_mem_common_neighbors [decidable_rel G.adj] (v w : V) :
decidable_pred (∈ G.common_neighbors v w) :=
λ a, and.decidable

lemma common_neighbors_top_eq {v w : V} :
(⊤ : simple_graph V).common_neighbors v w = set.univ \ {v, w} :=
by { ext u, simp [common_neighbors, eq_comm, not_or_distrib.symm] }

section incidence
variable [decidable_eq V]

Expand Down Expand Up @@ -503,6 +510,8 @@ locally finite at `v`.
-/
def neighbor_finset : finset V := (G.neighbor_set v).to_finset

lemma neighbor_finset_def : G.neighbor_finset v = (G.neighbor_set v).to_finset := rfl

@[simp] lemma mem_neighbor_finset (w : V) :
w ∈ G.neighbor_finset v ↔ G.adj v w :=
set.mem_to_finset
Expand Down Expand Up @@ -562,11 +571,14 @@ A locally finite simple graph is regular of degree `d` if every vertex has degre
-/
def is_regular_of_degree (d : ℕ) : Prop := ∀ (v : V), G.degree v = d

lemma is_regular_of_degree_eq {d : ℕ} (h : G.is_regular_of_degree d) (v : V) : G.degree v = d := h v
variables {G}

lemma is_regular_of_degree.degree_eq {d : ℕ} (h : G.is_regular_of_degree d) (v : V) :
G.degree v = d := h v

lemma is_regular_compl_of_is_regular [fintype V] [decidable_eq V]
(G : simple_graph V) [decidable_rel G.adj]
(k : ℕ) (h : G.is_regular_of_degree k) :
lemma is_regular_of_degree.compl [fintype V] [decidable_eq V]
{G : simple_graph V} [decidable_rel G.adj]
{k : ℕ} (h : G.is_regular_of_degree k) :
Gᶜ.is_regular_of_degree (fintype.card V - 1 - k) :=
by { intro v, rw [degree_compl, h v] }

Expand All @@ -583,6 +595,11 @@ lemma neighbor_finset_eq_filter {v : V} [decidable_rel G.adj] :
G.neighbor_finset v = finset.univ.filter (G.adj v) :=
by { ext, simp }

lemma neighbor_finset_compl [decidable_eq V] [decidable_rel G.adj] (v : V) :
Gᶜ.neighbor_finset v = (G.neighbor_finset v)ᶜ \ {v} :=
by simp only [neighbor_finset, neighbor_set_compl, set.to_finset_sdiff, set.to_finset_compl,
set.to_finset_singleton]

@[simp]
lemma complete_graph_degree [decidable_eq V] (v : V) :
(⊤ : simple_graph V).degree v = fintype.card V - 1 :=
Expand All @@ -591,7 +608,13 @@ begin
erw [degree, neighbor_finset_eq_filter, filter_ne, card_erase_of_mem (mem_univ v)],
end

lemma complete_graph_is_regular [decidable_eq V] :
lemma bot_degree (v : V) : (⊥ : simple_graph V).degree v = 0 :=
begin
erw [degree, neighbor_finset_eq_filter, filter_false],
exact finset.card_empty,
end

lemma is_regular_of_degree.top [decidable_eq V] :
(⊤ : simple_graph V).is_regular_of_degree (fintype.card V - 1) :=
by { intro v, simp }

Expand Down Expand Up @@ -632,11 +655,7 @@ defined to be a natural.
lemma le_min_degree_of_forall_le_degree [decidable_rel G.adj] [nonempty V] (k : ℕ)
(h : ∀ v, k ≤ G.degree v) :
k ≤ G.min_degree :=
begin
rcases G.exists_minimal_degree_vertex with ⟨v, hv⟩,
rw hv,
apply h
end
by { rcases G.exists_minimal_degree_vertex with ⟨v, hv⟩, rw hv, apply h }

/--
The maximum degree of all vertices (and `0` if there are no vertices).
Expand Down Expand Up @@ -750,6 +769,18 @@ begin
exact G.common_neighbors_subset_neighbor_set_left _ _ } }
end

lemma card_common_neighbors_top [decidable_eq V] {v w : V} (h : v ≠ w) :
fintype.card ((⊤ : simple_graph V).common_neighbors v w) = fintype.card V - 2 :=
begin
simp only [common_neighbors_top_eq, ← set.to_finset_card, set.to_finset_sdiff],
rw finset.card_sdiff,
{ congr' 1,
{ simp_rw [← finset.card_univ, ← set.to_finset_univ],
congr, },
{ simp [h], } },
{ simp only [←set.subset_iff_to_finset_subset, set.subset_univ] },
end

end finite

section maps
Expand Down
164 changes: 134 additions & 30 deletions src/combinatorics/simple_graph/strongly_regular.lean
Expand Up @@ -10,58 +10,162 @@ import data.set.finite

## Main definitions

* `G.is_SRG_of n k l m` (see `is_simple_graph.is_SRG_of`) is a structure for a `simple_graph`
satisfying the following conditions:
* `G.is_SRG_with n k ℓ μ` (see `simple_graph.is_SRG_with`) is a structure for
a `simple_graph` satisfying the following conditions:
* The cardinality of the vertex set is `n`
* `G` is a regular graph with degree `k`
* The number of common neighbors between any two adjacent vertices in `G` is `l`
* The number of common neighbors between any two nonadjacent vertices in `G` is `m`
* The number of common neighbors between any two adjacent vertices in `G` is ``
* The number of common neighbors between any two nonadjacent vertices in `G` is `μ`

## TODO
- Prove that the complement of a strongly regular graph is strongly regular with parameters
`is_SRG_of n (n - k - 1) (n - 2 - 2k + m) (v - 2k + l)`
- Prove that the parameters of a strongly regular graph
obey the relation `(n - k - 1) * m = k * (k - l - 1)`
obey the relation `(n - k - 1) * μ = k * (k - - 1)`
- Prove that if `I` is the identity matrix and `J` is the all-one matrix,
then the adj matrix `A` of SRG obeys relation `A^2 = kI + lA + m(J - I - A)`
then the adj matrix `A` of SRG obeys relation `A^2 = kI + ℓA + μ(J - I - A)`
-/

open finset

universes u

namespace simple_graph
variables {V : Type u}
variables (G : simple_graph V) [decidable_rel G.adj]

variables [fintype V] [decidable_eq V]
variables (G : simple_graph V) [decidable_rel G.adj]

/--
A graph is strongly regular with parameters `n k l m` if
A graph is strongly regular with parameters `n k ℓ μ` if
* its vertex set has cardinality `n`
* it is regular with degree `k`
* every pair of adjacent vertices has `l` common neighbors
* every pair of nonadjacent vertices has `m` common neighbors
* every pair of adjacent vertices has `` common neighbors
* every pair of nonadjacent vertices has `μ` common neighbors
-/
structure is_SRG_of (n k l m : ℕ) : Prop :=
structure is_SRG_with (n k ℓ μ : ℕ) : Prop :=
(card : fintype.card V = n)
(regular : G.is_regular_of_degree k)
(adj_common : ∀ (v w : V), G.adj v w → fintype.card (G.common_neighbors v w) = l)
(nadj_common : ∀ (v w : V), ¬ G.adj v w ∧ v ≠ w → fintype.card (G.common_neighbors v w) = m)
(of_adj : ∀ (v w : V), G.adj v w → fintype.card (G.common_neighbors v w) = )
(of_not_adj : ∀ (v w : V), v ≠ w → ¬G.adj v w → fintype.card (G.common_neighbors v w) = μ)

open finset
variables {G} {n k ℓ μ : ℕ}

/-- Empty graphs are strongly regular. Note that `ℓ` can take any value
for empty graphs, since there are no pairs of adjacent vertices. -/
lemma bot_strongly_regular :
(⊥ : simple_graph V).is_SRG_with (fintype.card V) 0 ℓ 0 :=
{ card := rfl,
regular := bot_degree,
of_adj := λ v w h, h.elim,
of_not_adj := λ v w h, begin
simp only [card_eq_zero, filter_congr_decidable, fintype.card_of_finset, forall_true_left,
not_false_iff, bot_adj],
ext,
simp [mem_common_neighbors],
end }

/-- Complete graphs are strongly regular. Note that the parameter `m` can take any value
for complete graphs, since there are no distinct pairs of nonadjacent vertices. -/
lemma complete_strongly_regular (m : ℕ) :
(⊤ : simple_graph V).is_SRG_of (fintype.card V) (fintype.card V - 1) (fintype.card V - 2) m :=
/-- Complete graphs are strongly regular. Note that ` can take any value
for complete graphs, since there are no distinct pairs of non-adjacent vertices. -/
lemma is_SRG_with.top :
(⊤ : simple_graph V).is_SRG_with (fintype.card V) (fintype.card V - 1) (fintype.card V - 2) μ :=
{ card := rfl,
regular := complete_graph_degree,
adj_common := λ v w (h : v ≠ w),
begin
simp only [fintype.card_of_finset, mem_common_neighbors, filter_not, ←not_or_distrib,
filter_eq, filter_or, card_univ_diff, mem_univ, if_pos, ←insert_eq, top_adj],
rw [card_insert_of_not_mem, card_singleton],
simp [h]
end,
nadj_common := λ v w (h : ¬(v ≠ w) ∧ _), (h.1 h.2).elim }
regular := is_regular_of_degree.top,
of_adj := λ v w h, begin
rw card_common_neighbors_top,
exact h,
end,
of_not_adj := λ v w h h', false.elim $ by simpa using h }

lemma is_SRG_with.card_neighbor_finset_union_eq {v w : V} (h : G.is_SRG_with n k ℓ μ) :
(G.neighbor_finset v ∪ G.neighbor_finset w).card =
2 * k - fintype.card (G.common_neighbors v w) :=
begin
apply @nat.add_right_cancel _ (fintype.card (G.common_neighbors v w)),
rw [nat.sub_add_cancel, ← set.to_finset_card],
{ simp [neighbor_finset, common_neighbors, set.to_finset_inter, finset.card_union_add_card_inter,
h.regular.degree_eq, two_mul], },
{ apply le_trans (card_common_neighbors_le_degree_left _ _ _),
simp [h.regular.degree_eq, two_mul], },
end
agusakov marked this conversation as resolved.
Show resolved Hide resolved

/-- Assuming `G` is strongly regular, `2*(k + 1) - m` in `G` is the number of vertices that are
adjacent to either `v` or `w` when `¬G.adj v w`. So it's the cardinality of
`G.neighbor_set v ∪ G.neighbor_set w`. -/
lemma is_SRG_with.card_neighbor_finset_union_of_not_adj {v w : V} (h : G.is_SRG_with n k ℓ μ)
(hne : v ≠ w) (ha : ¬G.adj v w) :
(G.neighbor_finset v ∪ G.neighbor_finset w).card = 2 * k - μ :=
begin
rw ← h.of_not_adj v w hne ha,
apply h.card_neighbor_finset_union_eq,
end
agusakov marked this conversation as resolved.
Show resolved Hide resolved

lemma is_SRG_with.card_neighbor_finset_union_of_adj {v w : V} (h : G.is_SRG_with n k ℓ μ)
(ha : G.adj v w) :
(G.neighbor_finset v ∪ G.neighbor_finset w).card = 2 * k - ℓ :=
begin
rw ← h.of_adj v w ha,
apply h.card_neighbor_finset_union_eq,
end
agusakov marked this conversation as resolved.
Show resolved Hide resolved

lemma compl_neighbor_finset_sdiff_inter_eq {v w : V} :
(G.neighbor_finset v)ᶜ \ {v} ∩ ((G.neighbor_finset w)ᶜ \ {w}) =
(G.neighbor_finset v)ᶜ ∩ (G.neighbor_finset w)ᶜ \ ({w} ∪ {v}) :=
by { ext, rw ← not_iff_not, simp [imp_iff_not_or, or_assoc, or_comm, or.left_comm], }

lemma sdiff_compl_neighbor_finset_inter_eq {v w : V} (h : G.adj v w) :
(G.neighbor_finset v)ᶜ ∩ (G.neighbor_finset w)ᶜ \ ({w} ∪ {v}) =
(G.neighbor_finset v)ᶜ ∩ (G.neighbor_finset w)ᶜ :=
begin
ext,
simp only [and_imp, mem_union, mem_sdiff, mem_compl, and_iff_left_iff_imp,
mem_neighbor_finset, mem_inter, mem_singleton],
rintros hnv hnw (rfl|rfl),
{ exact hnv h, },
{ apply hnw, rwa adj_comm, },
end
agusakov marked this conversation as resolved.
Show resolved Hide resolved

lemma is_SRG_with.compl_is_regular (h : G.is_SRG_with n k ℓ μ) :
Gᶜ.is_regular_of_degree (n - k - 1) :=
begin
rw [← h.card, nat.sub_sub, add_comm, ←nat.sub_sub],
exact h.regular.compl,
end
agusakov marked this conversation as resolved.
Show resolved Hide resolved

lemma is_SRG_with.card_common_neighbors_eq_of_adj_compl (h : G.is_SRG_with n k ℓ μ)
{v w : V} (ha : Gᶜ.adj v w) :
fintype.card ↥(Gᶜ.common_neighbors v w) = n - (2 * k - μ) - 2 :=
begin
simp only [←set.to_finset_card, common_neighbors, set.to_finset_inter, neighbor_set_compl,
set.to_finset_sdiff, set.to_finset_singleton, set.to_finset_compl, ←neighbor_finset_def],
simp_rw compl_neighbor_finset_sdiff_inter_eq,
have hne : v ≠ w := ne_of_adj _ ha,
rw compl_adj at ha,
rw [card_sdiff, ← insert_eq, card_insert_of_not_mem, card_singleton, ← finset.compl_union],
{ change (1 + 1) with 2,
rw [card_compl, h.card_neighbor_finset_union_of_not_adj hne ha.2, ← h.card], },
{ simp only [hne.symm, not_false_iff, mem_singleton], },
{ intro u,
simp only [mem_union, mem_compl, mem_neighbor_finset, mem_inter, mem_singleton],
rintro (rfl|rfl);
simpa [adj_comm] using ha.2, },
end

lemma is_SRG_with.card_common_neighbors_eq_of_not_adj_compl (h : G.is_SRG_with n k ℓ μ)
{v w : V} (hn : v ≠ w) (hna : ¬Gᶜ.adj v w) :
fintype.card ↥(Gᶜ.common_neighbors v w) = n - (2 * k - ℓ) :=
begin
simp only [←set.to_finset_card, common_neighbors, set.to_finset_inter, neighbor_set_compl,
set.to_finset_sdiff, set.to_finset_singleton, set.to_finset_compl, ←neighbor_finset_def],
simp only [not_and, not_not, compl_adj] at hna,
have h2' := hna hn,
simp_rw [compl_neighbor_finset_sdiff_inter_eq, sdiff_compl_neighbor_finset_inter_eq h2'],
rwa [← finset.compl_union, card_compl, h.card_neighbor_finset_union_of_adj, ← h.card],
end

/-- The complement of a strongly regular graph is strongly regular. -/
lemma is_SRG_with.compl (h : G.is_SRG_with n k ℓ μ) :
Gᶜ.is_SRG_with n (n - k - 1) (n - (2 * k - μ) - 2) (n - (2 * k - ℓ)) :=
{ card := h.card,
regular := h.compl_is_regular,
of_adj := λ v w ha, h.card_common_neighbors_eq_of_adj_compl ha,
of_not_adj := λ v w hn hna, h.card_common_neighbors_eq_of_not_adj_compl hn hna, }

end simple_graph
8 changes: 7 additions & 1 deletion src/data/fintype/basic.lean
Expand Up @@ -142,7 +142,13 @@ set.ext $ λ x, mem_compl

@[simp] lemma compl_empty : (∅ : finset α)ᶜ = univ := compl_bot

@[simp] lemma union_compl (s : finset α) : s ∪ sᶜ = finset.univ := sup_compl_eq_top
@[simp] lemma union_compl (s : finset α) : s ∪ sᶜ = univ := sup_compl_eq_top

@[simp] lemma inter_compl (s : finset α) : s ∩ sᶜ = ∅ := inf_compl_eq_bot

@[simp] lemma compl_union (s t : finset α) : (s ∪ t)ᶜ = sᶜ ∩ tᶜ := compl_sup

@[simp] lemma compl_inter (s t : finset α) : (s ∩ t)ᶜ = sᶜ ∪ tᶜ := compl_inf

@[simp] lemma compl_erase : (s.erase a)ᶜ = insert a sᶜ :=
by { ext, simp only [or_iff_not_imp_left, mem_insert, not_and, mem_compl, mem_erase] }
Expand Down
11 changes: 11 additions & 0 deletions src/data/set/finite.lean
Expand Up @@ -215,6 +215,8 @@ fintype.card_of_subsingleton _
lemma subsingleton.finite {s : set α} (h : s.subsingleton) : finite s :=
h.induction_on finite_empty finite_singleton

lemma to_finset_singleton (a : α) : ({a} : set α).to_finset = {a} := rfl
b-mehta marked this conversation as resolved.
Show resolved Hide resolved

lemma finite_is_top (α : Type*) [partial_order α] : finite {x : α | is_top x} :=
(subsingleton_is_top α).finite

Expand Down Expand Up @@ -756,6 +758,15 @@ lemma to_finset_union {α : Type*} [decidable_eq α] (s t : set α) [fintype (s
[fintype s] [fintype t] : (s ∪ t).to_finset = s.to_finset ∪ t.to_finset :=
by ext; simp

instance fintype_sdiff {α : Type*} [decidable_eq α]
kmill marked this conversation as resolved.
Show resolved Hide resolved
(s t : set α) [fintype s] [fintype t] :
fintype (s \ t : set α) :=
fintype.of_finset (s.to_finset \ t.to_finset) $ by simp

lemma to_finset_sdiff {α : Type*} [decidable_eq α] (s t : set α) [fintype s] [fintype t]
[fintype (s \ t : set α)] : (s \ t).to_finset = s.to_finset \ t.to_finset :=
by ext; simp

lemma to_finset_ne_eq_erase {α : Type*} [decidable_eq α] [fintype α] (a : α)
[fintype {x : α | x ≠ a}] : {x : α | x ≠ a}.to_finset = finset.univ.erase a :=
by ext; simp
Expand Down
2 changes: 1 addition & 1 deletion src/measure_theory/measure/outer_measure.lean
Expand Up @@ -702,7 +702,7 @@ lemma is_caratheodory_Union_lt {s : ℕ → set α} :

lemma is_caratheodory_inter (h₁ : is_caratheodory s₁) (h₂ : is_caratheodory s₂) :
is_caratheodory (s₁ ∩ s₂) :=
by { rw [← is_caratheodory_compl_iff, compl_inter],
by { rw [← is_caratheodory_compl_iff, set.compl_inter],
exact is_caratheodory_union _ (is_caratheodory_compl _ h₁) (is_caratheodory_compl _ h₂) }

lemma is_caratheodory_sum {s : ℕ → set α} (h : ∀i, is_caratheodory (s i))
Expand Down