/-
Copyright 2026 The Formal Conjectures Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-/
module
public import Mathlib.Combinatorics.SimpleGraph.Acyclic
public import Mathlib.Data.Real.Basic@[expose] public sectionnamespace SimpleGraphvariable {α : Type*} [Fintype α] [DecidableEq α]
largestInducedForestSize G is the size of a largest induced forest of G.
noncomputable def largestInducedForestSize (G : SimpleGraph α) : ℕ :=
sSup { n | ∃ s : Finset α, (G.induce s).IsAcyclic ∧ s.card = n }
largestInducedBipartiteSubgraphSize G is the size of a largest induced
bipartite subgraph of G.
noncomputable def largestInducedBipartiteSubgraphSize (G : SimpleGraph α) : ℕ :=
sSup { n | ∃ s : Finset α, (G.induce s).IsBipartite ∧ s.card = n }omit [Fintype α] inAn induced subgraph is bipartite exactly when its vertices admit a two-coloring.
theorem induce_isBipartite_iff_exists_coloring (G : SimpleGraph α) (s : Finset α) :
(G.induce s).IsBipartite ↔
∃ c : α → Fin 2, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v := α:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset α⊢ (induce (↑s) G).IsBipartite ↔ ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v
α:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset α⊢ (induce (↑s) G).IsBipartite → ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c vα:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset α⊢ (∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v) → (induce (↑s) G).IsBipartite
α:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset α⊢ (induce (↑s) G).IsBipartite → ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v α:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset αc:(induce (↑s) G).Coloring (Fin 2)⊢ ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v
α:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset αc:(induce (↑s) G).Coloring (Fin 2)⊢ ∀ u ∈ s,
∀ v ∈ s, G.Adj u v → (fun v ↦ if hv : v ∈ s then c ⟨v, hv⟩ else 0) u ≠ (fun v ↦ if hv : v ∈ s then c ⟨v, hv⟩ else 0) v
α:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset αc:(induce (↑s) G).Coloring (Fin 2)u:αhu:u ∈ sv:αhv:v ∈ shuv:G.Adj u v⊢ (fun v ↦ if hv : v ∈ s then c ⟨v, hv⟩ else 0) u ≠ (fun v ↦ if hv : v ∈ s then c ⟨v, hv⟩ else 0) v
α:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset αc:(induce (↑s) G).Coloring (Fin 2)u:αhu:u ∈ sv:αhv:v ∈ shuv:G.Adj u v⊢ c ⟨u, hu⟩ ≠ c ⟨v, hv⟩
All goals completed! 🐙
α:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset α⊢ (∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v) → (induce (↑s) G).IsBipartite α:Type u_1inst✝:DecidableEq αG:SimpleGraph αs:Finset αc:α → Fin 2hc:∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v⊢ (induce (↑s) G).IsBipartite
All goals completed! 🐙Computable largest induced bipartite subgraph size via powerset enumeration.
def computableLargestInducedBipartiteSubgraphSize (G : SimpleGraph α) [DecidableRel G.Adj] : ℕ :=
(Finset.univ.powerset.filter fun s : Finset α =>
∃ c : α → Fin 2, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v).sup Finset.card
The computable largest induced bipartite subgraph size agrees with the sSup definition.
a.h₁ α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adj⊢ ∃ c, ∀ u ∈ ∅, ∀ v ∈ ∅, G.Adj u v → c u ≠ c v
exact ⟨fun _ => 0, by α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adj⊢ ∀ u ∈ ∅, ∀ v ∈ ∅, G.Adj u v → (fun x ↦ 0) u ≠ (fun x ↦ 0) v simp All goals completed! 🐙⟩
· h₂ α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adj⊢ ∀ b ∈ {n | ∃ s, (induce (↑s) G).IsBipartite ∧ s.card = n},
b ≤ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v}.sup Finset.card rintro n ⟨s, hs, rfl⟩ h₂ α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adjs:Finset αhs:(induce (↑s) G).IsBipartite⊢ s.card ≤ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v}.sup Finset.card
apply Finset.le_sup h₂ α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adjs:Finset αhs:(induce (↑s) G).IsBipartite⊢ s ∈ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v}
exact Finset.mem_filter.mpr ⟨Finset.mem_powerset.mpr (Finset.subset_univ s),
(induce_isBipartite_iff_exists_coloring G s).mp hs⟩ All goals completed! 🐙
· a α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adj⊢ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v}.sup Finset.card ≤
sSup {n | ∃ s, (induce (↑s) G).IsBipartite ∧ s.card = n} apply Finset.sup_le a α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adj⊢ ∀ b ∈ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v},
b.card ≤ sSup {n | ∃ s, (induce (↑s) G).IsBipartite ∧ s.card = n}
intro s hs a α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adjs:Finset αhs:s ∈ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v}⊢ s.card ≤ sSup {n | ∃ s, (induce (↑s) G).IsBipartite ∧ s.card = n}
apply le_csSup a.h₁ α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adjs:Finset αhs:s ∈ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v}⊢ BddAbove {n | ∃ s, (induce (↑s) G).IsBipartite ∧ s.card = n}h₂ α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adjs:Finset αhs:s ∈ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v}⊢ s.card ∈ {n | ∃ s, (induce (↑s) G).IsBipartite ∧ s.card = n}
· a.h₁ α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adjs:Finset αhs:s ∈ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v}⊢ BddAbove {n | ∃ s, (induce (↑s) G).IsBipartite ∧ s.card = n} exact ⟨Fintype.card α, fun n ⟨t, _, ht⟩ => ht ▸ t.card_le_univ⟩ All goals completed! 🐙
· h₂ α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adjs:Finset αhs:s ∈ {s ∈ Finset.univ.powerset | ∃ c, ∀ u ∈ s, ∀ v ∈ s, G.Adj u v → c u ≠ c v}⊢ s.card ∈ {n | ∃ s, (induce (↑s) G).IsBipartite ∧ s.card = n} exact ⟨s, (induce_isBipartite_iff_exists_coloring G s).mpr
(Finset.mem_filter.mp hs).2, rfl⟩ All goals completed! 🐙
b G is the number of vertices of a largest induced bipartite subgraph of G.
Returned as a real number.
noncomputable def b (G : SimpleGraph α) : ℝ :=
(largestInducedBipartiteSubgraphSize G : ℝ)end SimpleGraph