import Mathlib import OAI.Combinatorics.IndependentSets.Reduction.Mixed namespace OAI namespace LargeIndependentSets section open scoped Classical namespace Graph noncomputable def enumeration_to_simple {W : Type} [Fintype W] [Nonempty W] (H : SimpleGraph W) [DecidableRel H.Adj] {n : ℕ} (hn : 0 rfl⟩ · rw [output,ite_eq_right hc,ite_eq_right hc] exact @Graph.enumeration_to_simple (p.Vertices L R C) inferInstance inferInstance (p.graph lc) inferInstance t ht ev variable (p : SamplerParameters) (q : ℕ) (hq : 0 he.colorable ((H U V L R C lc).1 h), fun h => he.strict_density ((H U V L R C lc).2 h)⟩ attribute [instance 1100] mixedTupleComputableFintype attribute [instance] mixedTupleDecidableEq end namespace SamplerParameters open scoped BigOperators attribute [-instance] mixedTupleComputableFintype mixedTupleDecidableEq def vertexEnumeration (p : SamplerParameters) {L R C : Type} [Fintype L] [Fintype R] [DecidableEq C] [DecidableEq (p.Vertices L R C)] (ec : ExplicitEnum C) (static : ExplicitEnum (p.Vertices L R Unit)) : ExplicitEnum (p.Vertices L R C) := ExplicitEnum.ofCover ((ExplicitEnum.pi (ExplicitEnum.fin p.n) (fun _ => ec)).values.flatMap (fun chain => static.values.map (fun o => (chain,o.2)))) (by rintro ⟨chain,o⟩ apply List.mem_flatMap.mpr refine ⟨chain,(ExplicitEnum.pi (ExplicitEnum.fin p.n) (fun _ => ec)).covers chain,?_⟩ exact List.mem_map.mpr ⟨(fun _ => (),o),static.covers _,rfl⟩) lemma vertexEnumeration_nonempty (p : SamplerParameters) {L R C : Type} [Fintype L] [Fintype R] [DecidableEq C] [DecidableEq (p.Vertices L R C)] [Nonempty C] (ec : ExplicitEnum C) (static : ExplicitEnum (p.Vertices L R Unit)) : 0 < (p.vertexEnumeration ec static).values.length := by classical have h := (p.vertexEnumeration ec static).covers (Classical.choice (inferInstance : Nonempty (p.Vertices L R C))) exact List.length_pos_iff.mpr (List.ne_nil_of_mem h) lemma vertexEnumeration_length (p : SamplerParameters) {L R C : Type} [Fintype L] [Fintype R] [Fintype C] [DecidableEq C] [DecidableEq (p.Vertices L R C)] (ec : ExplicitEnum C) (static : ExplicitEnum (p.Vertices L R Unit)) : (p.vertexEnumeration ec static).values.length ≤ Fintype.card C^p.n * static.values.length := by let xs := (ExplicitEnum.pi (ExplicitEnum.fin p.n) (fun _ => ec)).values have hh (xs : List (Fin p.n → C)) : (xs.flatMap (fun chain => static.values.map (fun o => (chain,o.2)))).length = xs.length * static.values.length := by induction xs with | nil => simp | cons x xs ih => simp only [List.flatMap_cons,List.length_append,List.length_map, List.length_cons,ih]; ring change List.length (List.dedup _) ≤ _ apply (List.dedup_sublist _).length_le.trans rw [hh] rw [ExplicitEnum.length_eq_card] simp only [Fintype.card_fun,Fintype.card_fin,le_refl] attribute [instance] mixedTupleDecidableEq attribute [instance 1100] mixedTupleComputableFintype def namedOutput (p : SamplerParameters) (q : ℕ) (hq : 0