/- 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 α] in

An 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 vc 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.

α: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, α: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 All goals completed! 🐙 α: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 α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adjs:Finset αhs:(induce (↑s) G).IsBipartites.card {s Finset.univ.powerset | c, u s, v s, G.Adj u v c u c v}.sup Finset.card α:Type u_1inst✝²:Fintype αinst✝¹:DecidableEq αG:SimpleGraph αinst✝:DecidableRel G.Adjs:Finset αhs:(induce (↑s) G).IsBipartites {s Finset.univ.powerset | c, u s, v s, G.Adj u v c u c v} All goals completed! 🐙 α: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} α: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} α: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} α: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}α: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} α: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} All goals completed! 🐙 α: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} 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